akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  for(int i=0;i<a.length();i++){
    int j;
    for(j=0;j<a.length();j++){
      if(a[j]!=b[(i+j)%a.length()]) {
        break;
      }
    }
    if(j==a.length()){
      cout<<"Yes\n";
      return 0;
    }
  }
  cout<<"No\n";
  return 0;
}

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

int main(void) {
	char str[201];
	int len, len2;
	
	scanf("%s", str);
	len = strlen(str);
	
	while(len >= 2) {
		len -= 2;
		len2 = len / 2;
		if (memcmp(str, str + len2, len2) == 0) {
			printf("%d\n", len);
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 128
# include <bits/stdc++.h>
# define ll long long
# define pb push_back
# define fi first
# define se second
# define mp make_pair
# define gcd(m,n)  __gcd(m, n)
# define pr_double(x) cout << fixed << setprecision(10) << x


using namespace std;

int main() {
    ll n,x,t;
    cin>>n>>x>>t;
    if(n<=x) cout<<t<<endl;
    else if(n%x==0) cout<<(n/x)*t<<endl;
    else
    {
        cout<<((n/x)+1)*t<<endl;
    }
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, k, s; cin >> n >> k >> s;
    vector<ll> a(n);

    ll min_a = 1;
    ll max_a = 1000000000;

    if(s == max_a){
        for(int i=0;i<k;i++){
            a[i] = s;
        }
        for(int i=k;i<n;i++){
            a[i] = min_a;
        }
    }else{
        for(int i=0;i<k;i++){
            a[i] = s;
        }
        for(int i=k;i<n;i++){
            a[i] = max_a;
        }
    }
    for(ll ai: a){
        cout << ai << " ";
    }
    cout << endl;
}


Measured memory_bytes: 2176
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	var su float64
	flag := true
	fmt.Scanf("%d", &n)

	nums := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%f", &nums[i])
	}

	s1 := nums[0]
	s2 := float64(0)
	for i := 1; i < n; i++ {
		s2 += nums[i]
	}

	diff := float64(s2 - s1)

	for i := 1; i < n; i++ {
		if flag {
			su = diff - 2 * nums[i]
			if su < 0 {
				flag = false
			}
		}

		if math.Abs(su) < diff {
			diff = math.Abs(su)
		}
	}
	fmt.Println(diff)
}

Measured memory_bytes: 512
import sys

input = sys.stdin.readline

def main():
    s = input().rstrip()
    t = input().rstrip()
    
    for i in range(len(s)):
        temp_word = ""
        for k in range(len(t)):
            if i + k <= len(s)-1:
                temp_word += s[i + k]
            else:
                temp_word += s[i + k - len(s)]
        if temp_word == t:
            print("Yes")
            sys.exit()
    
    print("No")
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 5568
import java.util.ArrayList;
import java.util.Scanner;

public class Main 
{
	static Scanner scan = new Scanner(System.in);
	static int n;
	static int a;
	static int b;

	public static void main(String[] args) 
	{
		while(true)
		{
			n = scan.nextInt();
			a = scan.nextInt();
			b = scan.nextInt();
			
			if(n == 0 && a == 0 && b == 0) {return;}
			
			int ans = n;
			
			//make a the smaller one and b the larger
			if(a > b)
			{
				int temp = a;
				a = b;
				b = temp;
			}
			
			int jump = b%a;
			//cost to jump = b
			
//			ArrayList<Integer> boffsets = new ArrayList<Integer>();
			
			for(int area = 0; true; area++)
			{
				int landed = (b*area)%a;
//				System.out.println("landed: " + landed);
				if(area != 0 && landed == 0) 
				{
					break;
					//went full circle
				}
//				boffsets.add(landed);
				
				int start = (b*area); //
				
				if(start > n)break;
				int end = (b*(area+1))-1; //
				
				
				int remove = (((n - start)/a) + 1);
				if(start == 0) {remove -= 1;}
//				System.out.println("[b * " + area + "] Can express: " + start + " + " + a + "k" + ", removing " + remove + " numbers");
				
				ans -= remove;
			}
			
			System.out.println(ans);
		}
	}

}



Measured memory_bytes: 26228
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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=1e9;
const int mod = 1000000007;

int main(){
  int N,L;
  cin>>N>>L;
  int MIN=INF,sum=0;
  int x=0;
  for(int i=1;i<=N;i++){
    sum+=L+i-1;
    if(MIN>abs(L+i-1)){MIN=abs(L+i-1);x=L+i-1;}
  }
  cout<<sum-x<<endl;
  return 0;                       
}

Measured memory_bytes: 3644
#include <bits/stdc++.h> 
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef double ld;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e17;																									
ll mpow(ll a,ll b){a=a%MOD;ll res=1;while(b>0){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b=b>>1;}return res%MOD;}             
 
int main()
{ 
ios_base::sync_with_stdio(false);
cin.tie(NULL);
///freopen("input.txt", "r", stdin);
ll n;
cin>>n;
ll a[n];
forn(i,n)
cin>>a[i];
ll c[n];
forn(i,n)
{
	c[i]=a[i]-i-1;
}
sort(c,c+n);
ll b=c[n/2];
ll ans=0;
forn(i,n)
{
	ans+=abs(a[i]-b-i-1);
}
cout<<ans;
return 0;    
} 

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

using namespace std;

#define ll long long
#define ff first
#define ss second
#define e endl

void solve() {
    string s; cin >> s;
    if(s[s.length()-1] == 's') s += "es";
    else s += 's';
    cout << s << e;
}

int main()
{
	//ll t; cin >> t; while (t--)
	solve();
}


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

using namespace std;

int main(){
  int h,w;cin>>h>>w;
  vector<string> board(h);
  for(int i=0;i<h;i++){
    cin>>board[i];
  }
  const int x[8] = {-1,0,1,-1,1,-1,0,1};
  const int y[8] = {1,1,1,0,0,-1,-1,-1};

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(board[i][j]=='#') continue;
      int cnt=0;
      for(int k=0;k<8;++k){
        const int iy = i + y[k];
        const int jx = j + x[k];
        if(iy<0 || h<=iy) continue;
        if(jx<0 || w<=jx) continue;
        if(board[iy][jx]=='#') cnt++;
      }
      board[i][j] = char(cnt+'0');
    }
  }
  for(int i=0;i<h;i++) cout<<board[i]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector< pair<int,int> > a(n);
  for(int i=0;i<n;i++){
    cin >> a[i].first;
    a[i].first++;
    a[i].second=i+1;
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
  	cout << a[i].second << " ";
  }
}


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

int N, M, K;
int A[111111];
int B[111111];
int C[111111];
int D[111111];
vector<int> F[111111];
vector<int> bl[111111];
int label[111111]; // 節点iのラベルはlebel[i]
map<int, int> label_cnt; // label[l]: ラベルlの連結成分の大きさ

// 連結成分の大きさを求める
int dfs(int now, int l) {
	label[now] = l;

	int ret = 0;
	for (int child : F[now]) {
		if (label[child] != 0) continue;
		ret += dfs(child, l) + 1;
	}

	return ret;
}

int main() {
	// 入力
	cin >> N >> M >> K;
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
		A[i]--, B[i]--;
		F[A[i]].push_back(B[i]);
		F[B[i]].push_back(A[i]);
	}

	for (int i = 0; i < K; i++) {
		cin >> C[i] >> D[i];
		C[i]--, D[i]--;
		bl[C[i]].push_back(D[i]);
		bl[D[i]].push_back(C[i]);
	}

	int l = 1; // ラベル番号
	for (int i = 0; i < N; i++) {
		if (label[i] != 0) continue;
		label_cnt[l] = dfs(i, l) + 1;
		l++;
	}

	for (int i = 0; i < N; i++) {
		int ans = label_cnt[label[i]] - 1 - F[i].size();
		for (int b : bl[i]) {
			if (label[b] == label[i]) {
				ans--;
			}
		}
		cout << ans << " ";
	}
	cout << endl;
}

Measured memory_bytes: 15488
N=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(N):
    S=input()
    if S=="AC":
        ac+=1
    elif S=="WA":
        wa+=1
    elif S=="TLE":
        tle+=1
    else:
        re+=1
print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)


    









        

    









    

        




    















    



    





    






        






    
















        


























            
    


    


    
    














    


    














Measured memory_bytes: 9192
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
 
using namespace std;

void solve(){

	return;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

  

	int n,ant,cont=1,aux;

	cin >> n;

	n--;
	cin >> ant;

	while(n--){
		cin >> aux;
		if(aux<ant){
			ant=aux;
			cont++;
		}
	}

	cout << cont << endl;
	
	return 0;
}

Measured memory_bytes: 256
var
	n,m,i,j:Longint;
	s:int64;
	d:array[1..1000]of int64;
	a,b,c:array[1..2000]of Longint;
begin
	read(n,m);
	for i:=1 to m do read(a[i],b[i],c[i]);
	for i:=2 to n do d[i]:=-1000000000000000000;
	for j:=1 to 2 do begin
		s:=d[n];
		for i:=1 to m do if d[b[i]]<d[a[i]]+c[i]then d[b[i]]:=d[a[i]]+c[i];
	end;
	if s<d[n]then writeln('inf')else writeln(s);
end.

Measured memory_bytes: 128
N = int(input())
S_P = []
for i in range(N):
    s,p = map(str, input().split())
    S_P.append([s,int(p),i+1])

S_P.sort(key=lambda x:x[1],reverse = True)
S_P.sort(key=lambda x:x[0])

for i in range(len(S_P)):
    print(S_P[i][2])

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

const int num[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

void chmax(string& a, string b) {
    if (a.size() < b.size())
        a = b;
    else if (a.size() == b.size() && a < b)
        a = b;
}

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

    string dp[11000];
    for (int i = 0; i <= N; i++){
        dp[i] = "-";
    }
    dp[0] = "";

    for (int i = 0; i <= N; i++) {
        if (dp[i] == "-") continue;
        for (auto a : A) {
            chmax(dp[i + num[a]], dp[i] + char(a + '0'));
        }
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 44928
#include <iostream>
#include <unordered_map>
using namespace std;
int main(){
	int n;
  	cin >> n;
  	unordered_map<string, int> m;
    for(int i=0;i<n;i++){
    	string s;
        cin >> s;
        m[s]++;
    }
  
    cout<<"AC  x  "<<m["AC"]<<endl;
    cout<<"WA  x  "<<m["WA"]<<endl;
    cout<<"TLE  x  "<<m["TLE"]<<endl;
    cout<<"RE  x  "<<m["RE"]<<endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int m = scan.nextInt();
        int n = scan.nextInt();
        int l = scan.nextInt();
        int[][] data = new int[m][n];
        int[][] datac = new int[n][l];
        long sum = 0;
        for(int i = 0 ; i < m ; i++){
            for(int j = 0 ; j < n ; j++){
                data[i][j]=scan.nextInt();
            }
        }
        for(int i = 0 ; i < n; i ++){
            for(int j = 0 ; j < l ; j++){
                datac[i][j]=scan.nextInt();
            }
        }
        for(int i = 0 ; i < m ; i++){
            for(int k = 0 ; k < l ; k++){
                for(int j = 0 ; j  <n; j++){
                    sum+=data[i][j]*datac[j][k];
                }
                System.out.print(sum);
                if(k+1<l) System.out.print(" ");
                sum=0;
            }
            System.out.println("");
        }
    }
}


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

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

    int res = A[0] - M;
    for(int i=0; i+1<N; ++i) res += max(A[i + 1] - A[i] - 2 * M, 0);
    res += max(T - M - A[N - 1], 0);
    
    cout << res << '\n';
}


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

/**
 * 課題B
 * @author ken2
 */
public class Main {

	/** 天気：晴れ */
	private static final String WATHER_SUNNY = "Sunny";
	/** 天気：曇り */
	private static final String WATHER_CLOUDY = "Cloudy";
	/** 天気：飴 */
	private static final String WATHER_RAINY = "Rainy";

	/**
	 * メイン処理
	 * @param args 起動引数
	 */
	public static void main(String[] args) {

		// 標準入力から今日の天気を取得
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String weather = null;
		try {
			weather = br.readLine();
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

		// 標準出力へ天気を出力
		if (weather.equals(WATHER_SUNNY)) {
			System.out.println(WATHER_CLOUDY); // Sunny→Cloudy
		}
		if (weather.equals(WATHER_CLOUDY)) {
			System.out.println(WATHER_RAINY); // Cloudy→Rainy
		}
		if (weather.equals(WATHER_RAINY)) {
			System.out.println(WATHER_SUNNY); // Rainy→Sunny
		}
	}
}


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

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int x=0,maxi=0;
	for(int i=1;i<=n;i++)
	{
		if(s[i-1]=='I')
		{
			x++;
			maxi=max(maxi,x);
		}
		else
			x--;
	}
	cout << maxi << endl;
}

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

int main(){
    int n = 0;
    std::cin >> n;
    std::vector<int> vec(n);
    int a = 0;

    for (int i = 1; i <= n; i++)
    {
        std::cin >> a;
        vec[a - 1] = i;
    }
    for (int i = 0; i < n; i++)
    {
        std::cout << vec[i] << std::endl;
    }

    return 0;
}

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

using namespace std;

int main(){
    long long int N,K,ans;
    cin >> N >> K;

    ans = K;

    vector<vector<int>> graph(N);
    vector<int> color(N,-1);

    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    queue<int> Q;
    Q.push(0);
    ans = K;
    color[0] = 0;

    while(!Q.empty()){
        int now = Q.front(),sub;
        Q.pop();

        if(now==0){
            sub = 1;
        }else{
            sub = 2;
        }

        for(int i=0;i<graph[now].size();i++){
            if(color[graph[now][i]]==-1){
                color[graph[now][i]] = 0;
                Q.push(graph[now][i]);
                ans *= (K-sub);
                ans %= 1000000007;
                sub++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6904
using System;
namespace std
{
    class Test 
    {
        static void Main(string[] args) {
            var input = Console.ReadLine().Split(' ');
            var W = int.Parse(input[0]);
            var H = int.Parse(input[1]);
            var x = int.Parse(input[2]);
            var y = int.Parse(input[3]);
            var r = int.Parse(input[4]);
        if(y - r < 0) Console.WriteLine("No");
        else if(y + r > H) Console.WriteLine("No");
        else if (x + r > W) Console.WriteLine("No");
        else if(x - r< 0) Console.WriteLine("No");
        else Console.WriteLine("Yes");
            
            
        }
        
    }
}


Measured memory_bytes: 17912
#include<bits/stdc++.h>
#include<stdio.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;


#define ll                  long long
#define scl(n)              scanf("%lld",&n)
#define scll(n, m)              scanf("%lld%lld",&n, &m)
#define scc(c)	            scanf("%c",&c)
#define fr(i,n)             for (ll i=0;i<n;i++)
#define fr1(i,n)            for(ll i=1;i<=n;i++)
#define pfl(x)              printf("%lld\n",x)
#define pb                  push_back
#define debug               cout<<"I am here"<<endl;
#define pno                 cout<<"NO"<<endl
#define pys                 cout<<"YES"<<endl
#define tcas(i,t)           for(ll i=1;i<=t;i++)
#define all(x) 	            (x).begin(), (x).end()
#define pr                  pair<ll, ll>
#define ff                  first
#define ss                  second

#define l(s)                s.size()
#define asort(a)            sort(a,a+n)
#define dsort(a)            sort(a,a+n,greater<int>())
#define vasort(v)           sort(v.begin(), v.end());
#define vdsort(v)           sort(v.begin(), v.end(),greater<int>());
#define uniquee(x)          x.erase(unique(x.begin(), x.end()),x.end())
#define pn                  printf("\n")
#define el                  cout<<endl
#define md                  1000000007
#define inf                 9e18
#define ps                  cout<<" ";
#define Pai                  acos(-1.0)
#define mem(a,i)            memset(a, i, sizeof(a))
#define pcas(i)             cout<<"Case "<<i<<": "<<endl;
#define fast 	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

#define N 200006

map<ll, ll>mp;
int main()
{

     ll i, j;
     double n, m, k;

     cin>>n;
     n=n/3;

    n=n*n*n;
    printf("%.7lf\n" , n);


return 0;
}

/// **************************Before submit****************************

///    ****Please check all base case output  and printing " YES or NO " ***
///    *check for integer overflow,array bounds
///    *check for n=1




Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int M[2],D[2];
  for(int i=0;i<2;i++){
    cin>>M[i]>>D[i];
  }
  cout<<(D[0]>D[1]?"1":"0")<<endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
A,B=map(int,input().split(' '))
P=list(map(int,input().split(' ')))
Q1=[p for p in P if p<=A]
Q2=[p for p in P if A<p<=B]
Q3=[p for p in P if B<p]
print(min(len(Q1),len(Q2),len(Q3)))

Measured memory_bytes: 3064
H,W,s=list(map(int,input().split()))
l=[list(input()) for i in range(H)]
l_h=[0]*H
for i in range(H):
   if "#" in set(l[i]):
      l_h[i]=1
cnt=0
bor=sum(l_h)-1
for i in range(H):
   if cnt==bor:
      break
   if l_h[i]==1:
      l_h[i]=-1
      cnt+=1
cnt=1
import numpy as np
tmp=[]
st=0
ans=np.zeros((H,W))
for i in range(H):
   tmp.append(l[i])
   if l_h[i]==-1:
      n_tmp=np.array(tmp)
      s_count=np.count_nonzero(n_tmp=="#")-1
      for j in range(W):
         ans[st:i+1,j]=cnt
         if "#" in n_tmp[:,j] and s_count>0:
            cnt+=1
            s_count-=1
      st=i+1
      cnt+=1
      tmp=[]
n_tmp=np.array(tmp)
s_count=np.count_nonzero(n_tmp=="#")-1
for j in range(W):
   ans[st:i+1,j]=cnt
   if "#" in n_tmp[:,j] and s_count>0:
      cnt+=1
      s_count-=1
for i in ans:
   print(*list(map(int,i)))

Measured memory_bytes: 28640
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline int read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline int _abs(const res &x){
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y){
    return x>y?x:y;
}
inline int _min(const res &x,const res &y){
    return x<y?x:y;
}
const int N=2e3+10;
namespace MAIN{
    int n,m;
    struct E{
        int next,to;
        E() {}
        E(res next,res to):next(next),to(to) {}
    }edge[N<<1];
    int head[N],cnt;
    inline void addedge(res u,res v){
        edge[++cnt]=E(head[u],v),head[u]=cnt;
        edge[++cnt]=E(head[v],u),head[v]=cnt;
    }
    int tot;
    void dfs(res x,res fax,res depx){
        if(depx>m/2)tot++;
        for(res i=head[x];~i;i=edge[i].next){
            res tox=edge[i].to;
            if(tox==fax)continue;
            dfs(tox,x,depx+1);
        }
    }
    int ans=inf;
    inline void MAIN(){
        memset(head,-1,sizeof(head));
        n=read(),m=read();
        for(res i=1;i<n;i++){
            res u=read(),v=read();
            addedge(u,v);
        }
        if(m&1){
            for(res x=1;x<=n;x++)
                for(res i=head[x];~i;i=edge[i].next){
                    res tox=edge[i].to;
                    tot=0;
                    dfs(tox,x,0);
                    dfs(x,tox,0);
                    ans=_min(ans,tot);
                }
        }
        else {
            for(res x=1;x<=n;x++)
                tot=0,dfs(x,0,0),ans=_min(ans,tot);
        }
        printf("%d\n",ans);
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;

string a, b;

int main(void) {
	cin >> a;
	FOR(i, 0, a.size()) {
		if (a[i] == 'B') {
			if(!b.empty())b.pop_back();
		}
		else {
			b += a[i];
		}
	}
	ct(b);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    set<int> s;
    int now;
    cin >> now;
    int i = 1;
    while(true){
        s.insert(now);
        if(now%2) now = 3*now+1;
        else now /= 2;
        i++;
        if(s.count(now)){
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
def warshall_floyed(n):
    global d
    for m in range(n):
        for s in range(n):
            for t in range(n):
                d[s][t] = min(d[s][t],
                              d[s][m] + d[m][t])
                
if __name__ == "__main__":
    H,W = map(int, input().split())
    d = [list(map(int, input().split())) for _ in range(10)]
    warshall_floyed(10)
    cnt = [0]*10
    for h in range(H):
        a = list(map(int, input().split()))
        for ai in a:
            if ai>-1:
                cnt[ai]+=1
    ans = 0
    for i in range(10):
        ans += cnt[i]*d[i][1]
    print(ans)

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**9)

t = int(input())
for _ in range(t):
    n, a, b, c, d = map(int, input().split())
    memo = {0: n * d}

    def dfs(m, cost):
        if m not in memo or memo[m] > cost:
            memo[m] = cost
            memo[0] = min(memo[0], cost + m * d)

            if m > 0:
                dfs(m // 2, cost + (m % 2) * d + a)
                dfs(m // 3, cost + (m % 3) * d + b)
                dfs(m // 5, cost + (m % 5) * d + c)

                dfs((m + (2 - m % 2)) // 2, cost + (2 - m % 2) * d + a)
                dfs((m + (3 - m % 3)) // 3, cost + (3 - m % 3) * d + b)
                dfs((m + (5 - m % 5)) // 5, cost + (5 - m % 5) * d + c)

    dfs(n, 0)
    print(memo[0])


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

vector<long long int> a,b,c;

int main() {

    int n;

    cin >> n;

    for(int i=0; i<n; i++){
        long long int ai;
        cin >> ai;
        a.push_back(ai);
    }

    for(int i=0; i<n; i++){
        long long int bi;
        cin >> bi;
        b.push_back(bi);
    }

    for(int i=0; i<n; i++){
        long long int ci;
        cin >> ci;
        c.push_back(ci);
    }

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

    long long int ans = 0;

    for(int i=0; i<n; i++){
        long long int lock_num = b[i];
        auto a_itr = lower_bound(a.begin(),a.end(),lock_num);
        auto c_itr = upper_bound(c.begin(),c.end(),lock_num);
        long long int a_num = a_itr - a.begin();
        long long int c_num = c.end() - c_itr;

        ans += a_num * c_num;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000LL;
constexpr auto MOD = 1000000007;

vi a = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

int main() {
	
	int k;
	cin >> k;
	cout << a[k - 1] << endl;

}

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

using LL = long long;

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

  string ans;
  int N;
  cin >> N;

  int temp = N;
  int S = 0;
  while (temp > 0) {
    S += temp % 10;
    temp /= 10;
  }

  if (N % S) {
    ans = "No";
  } else {
    ans = "Yes";
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
//const double EPS = 1e(-12);
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.first == b.first)
    {
        return a.second < b.second;
    }
    return a.first < b.first;
}
ll n, k;
vector<ll> w;

bool f(ll P)
{
    ll t = 0;
    int cnt = 1;
    for (int i = 0; i < n; i++)
    {
        if (P < w[i])
            return false;

        if (t + w[i] > P)
        {
            cnt++;
            t = w[i];
        }
        else
        {
            t += w[i];
        }
    }
    
    if (cnt <= k)
        return true;
    else
        return false;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);

    cin >> n >> k;
    w.resize(n);

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

    ll l = -1, r = 100000 * 10000;
    while (r - l > 1)
    {
        ll mid = (l + r) / 2;
        if (f(mid))
        {
            r = mid;
        }
        else
        {
            l = mid;
        }
    }
    cout << r << endl;
    return 0;
}


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

int main(){
    string str;
    stack<char> st;
    vector<char> v;
    getline(cin,str);
    for(int i=0;str[i];i++){
        if(str[i]=='B'){
            if(!st.empty()){
                st.pop();
            }
        }else{
            st.push(str[i]);
        }
    }
    while(!st.empty()){
        v.push_back(st.top());
        st.pop();
    }
    for(int i=v.size()-1;i>=0;i--){
        cout<<v[i];
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(long long i = 0; i < n; ++i)
#define FOR(i, a, b) for(long long i = a; i < b; ++i)
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main() {
    int q;
    int c, a, n;
    int cnt, minv;
    scanf("%d", &q);
    while (q--) {
        cnt = 0;
        scanf("%d%d%d", &c, &a, &n);
        if (c >= 1 && a >= 1 && n >= 1) {
            minv = min({c, a, n});
            cnt += minv;
            c -= minv; a -= minv; n -= minv;
        }
        if (c >= 2 && a >= 1) {
            minv = min(c / 2, a);
            cnt += minv;
            c -= minv * 2; a -= minv;
        }
        if (c >= 3) {
            cnt += c / 3;
        }

        printf("%d\n", cnt);
    }

    return 0;
}




Measured memory_bytes: 3220
#include <stdio.h> 
 #include <string.h> 
 #define MAX 100 
 
 
 int main(){ 
     int n; 
     int t_point=0, h_point=0; 
     char tarou[MAX], hanako[MAX]; 
 

    scanf("%d", &n); 
     for(;n>0;n--){ 
         scanf(" %s %s", tarou, hanako); 
         if(strcmp(tarou, hanako)>0){ 
             t_point+=3; 
         }else if(strcmp(tarou, hanako)==0){ 
           t_point+=1; 
             h_point+=1; 
         }else if(strcmp(tarou, hanako)<0){ 
             h_point+=3; 
         } 
     } 
     printf("%d %d\n", t_point, h_point); 
 
 
     return 0; 
 } 



Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
int main(){
    string s;
    int x,y;
    cin>>s>>x>>y;
    vector<int> T,Y;
    int a=0,b=0;
    rep(i,s.size()){
        if(s[i]=='F') b++;
        else{
            if(b>0){
                if(a%2) Y.push_back(b);
                else T.push_back(b);
            }
            b=0,a++;
        }
    }
    if(b>0){
        if(a%2) Y.push_back(b);
        else T.push_back(b);
    }
    int dp[2][16010]={0},z=1;
    dp[0][8005]=1;
    rep(i,T.size()){
        rep(j,16010){
            if(0<=j+T[i]&&j+T[i]<16010) dp[(i+1)%2][j+T[i]]=(dp[(i+1)%2][j+T[i]]||dp[i%2][j]);
            if(s[0]=='T'||i>0)if(0<=j-T[i]&&j-T[i]<16010) dp[(i+1)%2][j-T[i]]=(dp[(i+1)%2][j-T[i]]||dp[i%2][j]);
        }
        fill(dp[i%2],dp[i%2]+16010,0);
    }
    if(!dp[T.size()%2][8005+x]) z=0;
    fill(dp[0],dp[0]+16010,0);
    fill(dp[1],dp[1]+16010,0);
    dp[0][8005]=1;
    rep(i,Y.size()){
        rep(j,16010){
            if(0<=j+Y[i]&&j+Y[i]<16010) dp[(i+1)%2][j+Y[i]]=(dp[(i+1)%2][j+Y[i]]|dp[i%2][j]);
            if(0<=j-Y[i]&&j-Y[i]<16010) dp[(i+1)%2][j-Y[i]]=(dp[(i+1)%2][j-Y[i]]|dp[i%2][j]);
        }
        fill(dp[i%2],dp[i%2]+16010,0);
    }
    if(!dp[Y.size()%2][8005+y]) z=0;
    if(z) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define dump(X) cout << #X << ' ' << X << endl
#define pe(X) cout << X << endl
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int main(){
	int r;
	cin >> r;
	cout << 3*r*r << endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b, bool equal = false){
    if(a < b || equal && a == b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b, bool equal = false){
    if(b < a || equal && a == b){
        a = b;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;

    double ans = 0;
    reps(i, n){
        if(i & 1){
            ans += 1.0;
        }
    }
    ans /= (double)n;
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    string s,t;cin>>s>>t;
    ll n=s.size(),m=t.size();
    vvi dp(n+1,vi(m+1));
    rep(i,n)rep(j,m){
        if(s[i]==t[j])dp[i+1][j+1]=dp[i][j]+1;
        chmax(dp[i+1][j+1],dp[i+1][j]);
        chmax(dp[i+1][j+1],dp[i][j+1]);
    }
    int wi=n,wj=m;
    vector<char> ans;
    while(wi!=0&&wj!=0){
        if(wi>0&&dp[wi][wj]==dp[wi-1][wj])wi--;
        else if(wj>0&&dp[wi][wj]==dp[wi][wj-1])wj--;
        else{
            ans.eb(s[wi-1]);
            wi--;wj--;
        }
    }
    for(int i=ans.size()-1;i>=0;i--)cout<<ans[i];
    cout<<endl;
}

Measured memory_bytes: 70784
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	while(cin >> n && n)
	{
		vint v(n);
		rep(i, n)
			cin >> v[i];

		cout << (accumulate(ALL(v), 0) - *max_element(ALL(v)) - *min_element(ALL(v))) / (n - 2) << endl;
	}
}

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

int main (void){
	char s[10];
	int y,m,d;
	cin >> s;
	y=1000*(s[0]-'0')+100*(s[1]-'0')+10*(s[2]-'0')+(s[3]-'0');
	m=10*(s[5]-'0')+(s[6]-'0');
	if(y<=2018) cout << "Heisei" << endl;
	else if(y==2019&&m<=4) cout << "Heisei" << endl;
	else cout << "TBD" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef int ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    string s;cin>>s;
    ll n=s.size();
    vector<ll>ma(1LL<<26,-1);
    ma[0]=0;
    ll now=0;
    ll ans=n;
    rep(i,n){
        now^=(1LL<<(s[i]-'a'));
        ll tmp=inf;
        rep(j,26){
            if(ma[(1LL<<j)^now]!=-1){
                tmp=min(tmp,ma[(1LL<<j)^now]+1);
            }
        }
        if(ma[now]!=-1){
            tmp=min(tmp,ma[now]);
        }
        if(tmp!=inf){
            ma[now]=tmp;
            if(i==n-1){
                ans=min(ans,tmp);
            }
        }
        //cout<<tmp<<endl;
    }
    if(ans==0)ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 265800
package main

import "fmt"

func ContainsInt(arr []int, i int) bool {
	for _, a := range arr {
		if a == i {
			return true
		}
	}
	return false
}

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	g1 := []int{1, 3, 5, 7, 8, 10, 12}
	g2 := []int{4, 6, 9, 11}
	g3 := []int{2}
	if (ContainsInt(g1, x) && ContainsInt(g1, y)) || (ContainsInt(g2, x) && ContainsInt(g2, y)) || (ContainsInt(g3, x) && ContainsInt(g3, y)) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  int s;
  cin >> N >> A;
  
  s = A - (N % 500);
  if (s >= 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    For(i,n) for(int i=0;i<n;i++)
#define    rFor(i,n) for(int i=n-1;i>=0;i--)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    all(v) v.begin(),v.end()
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    test   int t;cin>>t;for(int l=0;l<t;l++)
#define    min3(a,b,c)     min(a,min(b,c))
#define    max3(a,b,c)     max(a,max(b,c))
#define    min4(a,b,c,d)   min(min(a,b),min(c,d))
#define    max4(a,b,c,d)   max(max(a,b),max(c,d))
#define    Max(a)  *max_element(a,a+sizeof(a)/sizeof(a[0]))
#define    Min(a)  *min_element(a,a+sizeof(a)/sizeof(a[0]))
#define    nl     "\n"
#define    End    return 0 
#define    gt     greater<int>()
#define    ll     long long 
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    vl     vector<ll>
#define    mod    1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    pi     acos(-1)

int main()
{
MP;
    //test
    {
        int a,b,c;
        cin>>a>>b>>c;
        if(a<=(b*c))cout<<"Yes";
        else cout<<"No";
    }
    
End;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int x,n;
  cin >> x>>n;
  if(n==0){
    cout << x;
    return 0;
  }
  vector<int> p(n);
  vector<bool> q(102,false);
  rep(i,n){
    cin >> p.at(i);
    q.at(p.at(i))=true;
  }
  int ans=1000;
  int cotae=1000;
  for(int i=0;i<102;i++){
    if(q.at(i)==false && ans>abs(x-i)){
      ans=min(ans,abs(i-x));
      cotae=i;
    }
  }
  cout << cotae;
}
    
  


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

int main(){
  int n,l;
  cin>> n >> l;
  
  int last=l+n-1;
  int ans=(l+last)*n/2;//n個のリンゴの味の和
  if (0<l){         //味lのリンゴを食べる
    ans-=l;
  }
  else if (last<0){ //味lastのリンゴを食べる
    ans-=last;
  }                 //l<=0<=last ならば味0のリンゴを食べる  
  cout<< ans <<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)


def dfs(v, remove):
    for u in tree[v]:
        if u not in visited and [v, u] != remove and [u, v] != remove:
            visited.add(u)
            dfs(u, remove)


n, m = map(int, input().split())
tree = [[] for _ in range(n)]
k = []
for _ in range(m):
    a, b = map(int, input().split())
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)
    k.append([a - 1, b - 1])

res = 0
for a, b in k:
    visited = set()
    dfs(0, [a, b])
    if len(visited) < n:
        res += 1
print(res)


Measured memory_bytes: 3064
from math import floor,ceil,sqrt
import fractions
from collections import deque
import itertools
import collections
from heapq import *
def modpow(a,n,p):
    if n==0:
        return 1
    x=modpow(a,n//2,p)
    x=(x*x)%p
    if (n%2)==1:
        x=(x*a)%p
    return x%p
def modinv(a,p):
    return modpow(a,p-2,p)

S=int(input())
p=10**9+7
frac=[1]*10000
fracinv=[1]*10000
fracinv[0]=modinv(1,p)
for i in range(10000-1):
    frac[i+1]=(frac[i]*(i+1))%p
    fracinv[i+1]=modinv(frac[i+1],p)
ans=0
#print(frac[0:6])
for i in range(1,1000):
    num=S-3*i
    if num<0:
        break
    else:
        left=num+i-1
        right=i-1
        ans=(ans+(frac[left]*fracinv[left-right]*fracinv[right])%p)%p
print(ans)



Measured memory_bytes: 74120
def pow(a, n, mod):
    ret = 1
    pw = a
    while n > 0:
        if n & 1 == 1:
            ret *= pw
            ret %= mod
        n >>= 1
        pw *= pw
        pw %= mod
    return ret


def main():
    MOD = 10 ** 9 + 7
    N, K = list(map(int, input().split(' ')))
    n_gcds = [0 for _ in range(K + 1)]
    for g in range(K, 0, -1):
        v = pow(K // g, N, MOD)
        gg = g
        while gg + g <= K:
            gg += g
            v -= n_gcds[gg]
            v %= MOD
        n_gcds[g] = v
    ans = 0
    for g, n in enumerate(n_gcds):
        ans += g * n
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11284
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut it = buf.trim().split_whitespace();

    let n: usize = it.next().unwrap().parse().unwrap();
    let k: usize = it.next().unwrap().parse().unwrap();
    let r: u64 = it.next().unwrap().parse().unwrap();
    let s: u64 = it.next().unwrap().parse().unwrap();
    let p: u64 = it.next().unwrap().parse().unwrap();
    let t: Vec<char> = it.next().unwrap().chars().collect();

    let mut point: u64 = 0;
    let mut flag: Vec<usize> = Vec::new();

    for i in 0..n {
        if i < k {
            point += match t[i] {
                'r' => p,
                's' => r,
                'p' => s,
                _ => 0,
            }
        } else if t[i] != t[i - k] || flag.contains(&(i - k)) {
            point += match t[i] {
                'r' => p,
                's' => r,
                'p' => s,
                _ => 0,
            }
        } else {
            flag.push(i);
        }
    }

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


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

const int mod=1e9+7;
int n, m, dp[1002][1002];
string grid[1002];

int main(){
	memset(dp,0,sizeof dp);
	cin >> n >> m;
	for (int i=0;i<n;i++) cin >> grid[i];
	dp[0][0]=1;
	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++){
			if (grid[i][j]=='.'){
				dp[i+1][j]+=dp[i][j];
				dp[i+1][j]%=mod;
				dp[i][j+1]+=dp[i][j];
				dp[i][j+1]%=mod;
			}
		}
	}
	cout << dp[n-1][m-1] << "\n";
}

Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;
using ll = long long;


int main() {
    ll x, k, d; cin >> x >> k >> d;
    x = abs(x);
    if (x / d < k) {
        k -= x / d;
        ll a = x % d;
        ll b = abs(a - d);
        cout << ((k & 1) ? b : a) << endl;
    } else {
        cout << x - d * k << endl; 
    }
    return 0;
}

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

long long a, b, c, x, y;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> a >> b >> c >> x >> y;
	b = min(b, 2 * c);
	a = min(a, 2 * c);
	
	if(2 * c >= (a + b))
		return cout << 1LL * x * a + 1LL * y * b, 0;
	long long t = min(x, y);
	x -= t; y -= t;
	cout << 1LL * t * 2 * c + 1LL * x * a + 1LL * y * b;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	string S, T; cin >> S >> T;
	string res;
	for (int i = 0; i < S.length();i++) {
		if (i + T.length() > S.length())break;
		bool f = false;
		for (int j = 0; j < T.length();j++) {
			if (S[i + j] == '?')continue;
			if (S[i + j] == T[j]) continue;
			f = true;
		}
		if (f)continue;

		string t;
		for (int j = 0; j < S.length();j++) {
			if (j < i) {
				if (S[j] == '?')t += 'a';
				else t += S[j];
			}
			else {
				if (j < i + T.length()) {
					t += T[j - i];
				}
				else {
					if (S[j] == '?')t += 'a';
					else t += S[j];
				}
			}
		}
		if (res.length() == 0)res = t;
		else res = min(res, t);
	}
	if (res.length() == 0) {
		cout << "UNRESTORABLE" << endl;
	}
	else {
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
H = [int(i) for i in input().split()]

dp = [float("inf")] * N
dp[0], dp[1] = 0, abs(H[1]-H[0])
for i in range(2, N):
    dp[i] = min(dp[i], dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]))
    
print(dp[N-1])

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

int main() {
  int N,W;
  cin >> N >> W;
  vector<int> w(N),v(N);
  for(int i=0;i<N;i++){
    cin >> w[i] >> v[i];
  }
  vector<vector<long long>> dp(N+1,vector<long long>(W+1,0));
  
  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      if(j<w[i])
        dp[i+1][j]=dp[i][j];
      else
        dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
    }
  }
  cout << dp[N][W] << endl;
}


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

int main(void){
    int n, k;
    cin >> n >> k;
    
    long double ans = 0;
    for(int i = 1; i <= n; i++){
        long double cnt = 1;
        for(int j = i; j < k; j *= 2){
            cnt /= 2.0;
        }
        ans += cnt;
    }
    
    ans /= (long double)n;
    
    printf("%.10Lf\n", ans);
    
    return 0;
}


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

int main() {
  	int n; cin>>n;
  	long double z = 0;
  	for (int i = 0 ; i < n; i++) {
		int a; cin>>a;
      	z += (long double) 1 / a;
    }
  	cout << setprecision(30) << 1/z << endl;
  return 0;
}

Measured memory_bytes: 256