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

int main(){

  for (int i = 0;true;i++){
    int h,w;
    cin >> h >> w;

    if (h == 0 && w ==0) break;

    for (int j = 1; j <=h; j++){
      for (int k = 1; k <= w; k++){
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;

}

Measured memory_bytes: 3068
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    string s; cin >> s;
    int q; cin >> q;
    
    bool fliped = false;

    string front = "";
    string back = "";
    rep(i,q) {
        int t; cin >> t;
        if (t == 1) {
            if (fliped) fliped = false;
            else fliped = true;
            continue;
        }
        else if (t == 2) {
            int f; char c;
            cin >> f >> c;
            if (f == 1) {
                if (fliped) back.push_back(c);
                else front.push_back(c);
            } 
            else if (f == 2) {
                if (fliped) front.push_back(c);
                else back.push_back(c);
                
            }
        }

    }
    reverse(all(front));
    s = front + s + back;
    if (fliped) reverse(all(s));
    cout << s << endl;
    return 0;
}




























Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> *i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

struct union_find {
    vector<int> data;
    union_find(int size) : data(size, -1) { }
    void unite(int x, int y) {
        x = root(x); y = root(y);
        if(x != y) {
            if(data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

signed main() {
    int n;
    cin>>n;
    vector<int> a(n);
    cin>>a;

    union_find uf(n);
    vector<pii> p(n);
    REP(i,n) p[i]={a[i],i};
    vector<bool> u(n,false);
    sort(RALL(p));

    int ans=0;
    REP(i,n) {
        u[p[i].second]=true;

        int l=0,r=0;
        if(p[i].second>0 && u[p[i].second-1]) {
            l=uf.size(p[i].second-1);
            uf.unite(p[i].second-1,p[i].second);
        }
        if(p[i].second<n-1 && u[p[i].second+1]) {
            r=uf.size(p[i].second+1);
            uf.unite(p[i].second,p[i].second+1);
        }
        
        ans+=p[i].first*(l+1)*(r+1);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6528
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;

static class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        Console.WriteLine(s[0] == s[1] || s[1] == s[2] || s[2] == s[3] ? "Bad": "Good");
    }
}



Measured memory_bytes: 11092
#include<stdio.h>
#include<string.h>
int a[9]={0},n,t;
int main()
{
	for(;scanf("%d",&n),n;memset(a,0,36))
	{
		for(;n--;t/10>6?a[6]++:a[t/10]++)
			scanf("%d",&t);
		for(n=0;n<7;n++)
			printf("%d\n",a[n]);
	}
	return 0;
}

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

//h, w, dir, P, Q
typedef struct _State{
    int h, w, dir;
    vector<int> pq;
    
    bool operator < (const _State r)const{
        return r.h == h? r.w == w? r.dir==dir? r.pq < pq: r.dir<dir: r.w < w:r.h < h;
    }
}State;

int N, M, A;
int Sh, Sw, Gh, Gw;
vector<string> field;

//south is 0
int dh[] = {1, -1, 0, 0};
int dw[] = {0, 0, 1, -1};

int table[2][4] = {{2, 3, 0, 1}, {3, 2, 1, 0}};

int bfs(){
    queue<State> que;
    map<State, int> dist;
    State s = State({Sh, Sw, 0, {A, A}});
    que.push(s);
    dist[s] = 0;
    
    while(!que.empty()){
        State u = que.front(); que.pop();
        for(int nh=u.h+dh[u.dir], nw=u.w+dw[u.dir]; 0<=nh&&nh<N && 0<=nw&&nw<M && field[nh][nw]!='#'; nh+=dh[u.dir], nw+=dw[u.dir]){
            if(nh == Sh && nw == Sw && u.dir == 1) break;
            
            for(int i=-1; i<2; i++){
                if(nh == Sh && nw == Sw && i>=0) break;
                
                State v({nh, nw, u.dir, u.pq});
                if(i >= 0){
                    if(u.pq[i] == 0) continue;
                    v.pq[i]--;
                    v.dir = table[i][u.dir];
                }
                
                if(dist.find(v) == dist.end()){
                    dist[v] = dist[u];
                    if(i >= 0)
                        dist[v]++;
                    if(v.h == Gh && v.w == Gw)
                        return dist[v];
                    //cout << v.h << " " << v.w << " " << dist[v] << endl;
                    que.push(v);
                }
            }
        }
    }
    return -1;
}

int main(){
    cin >> N >> M >> A;
    field.resize(N);
    for(auto &s: field) cin >> s;
    
    for(int i=0; i<N; i++) for(int j=0; j<M; j++){
        if(field[i][j] == 'S')
            Sh = i, Sw = j;
        if(field[i][j] == 'G')
            Gh = i, Gw = j;
    }
    cout << bfs() << endl;
    
    return 0;
}

Measured memory_bytes: 19356
#include<iostream>

int main(){
    int a,b,c,i,cnt=0;
    std::cin>> a>> b>> c;
    for(i=1;i<=c;i++){
        if(c%i==0){
            if(a<=i&&i<=b) cnt++;
        }
    }
    std::cout<< cnt<< std::endl;
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define int long long int
#define hell (int)(1e9+7)
#define inf 1000000000000

using namespace std;

int modi[300005];

int power(int x,int n){
    if(n==0)
        return 1;
    if(n%2==0)
        return power((x*x)%hell,n/2)%hell;
    else
        return (x*power((x*x)%hell,n/2))%hell;
}



int ncr(int n,int r){
    int res=1;
    for(int i=0;i<r;i++){
        res=(res*(n-i))%hell;
        res=(res*modi[r-i])%hell;
    }
    return res;
}

void solve(){
    for(int i=1;i<300005;i++)
        modi[i]=power(i,hell-2);
    int n,a,b;
    cin>>n>>a>>b;
    int ans=power(2,n);
    ans=(ans-ncr(n,a)-ncr(n,b)-1)%hell;
    ans=(ans+hell)%hell;
    cout<<ans;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t,c;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 2560
from collections import defaultdict

N, M = map(int, input().split())

prime = defaultdict(int)
m = M
for i in range(2, 10 ** 5):
    while m % i == 0 and m > 1:
        prime[i] += 1
        m //= i

if m > 1:
    prime[m] = 1
MOD = 10 ** 9 + 7

def comb(n, k):
    a = 1
    for i in range(1, k + 1):
        a *= n - i + 1
        a %= MOD
        
        a *= pow(i, MOD - 2, MOD)
        a %= MOD
        
    return a

ans = 1
for _, t in prime.items():
    ans *= comb(N - 1 + t, t)
    ans %= MOD
    
print(ans)



Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#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 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>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
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 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");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  ll n; cin>>n;
  vi a(n),b(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  //Yes or No
  vi c(200001,0),d(200001,0);
  rep(i,n) c[a[i]]++;
  rep(i,n) d[b[i]]++;
  bool f=true;
  rep(i,200001) if(c[i]+d[i]>n) f=false;
  YesNo(f);
  ll p=0;
  vi ans(n);
  //show example
  if(f){
    REP(i,1,200001){
      c[i]+=c[i-1];
      d[i]+=d[i-1];
    }
    REP(i,1,200001) chmax(p,c[i]-d[i-1]);
    rep(i,n) ans[(i+p)%n]=b[i];
    outv(ans);
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


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


#define int unsigned long long

int lcm(int a, int b){
  return __gcd(a,b)*a*b;
}

signed main(){
  int n, t = 1, a = 1;
  int tt, aa, t1, a1;

  cin>>n;

  for(int i = 1;  i <= n; i++){
    cin>>t1>>a1;
    int l = 0, r = (int)(1e19), m;
    r/=max(t1,a1);
    for(int i = 1; i < 100; i++){//cout<<i<<" "<<m<<" "<<l<<" "<<r<<endl;
      m = (l + r)/2;
      if((t1*m >= t) && (a1*m >= a)) r = m;
      else l = m+1;
    }
    t = t1*m;
    a = a1*m;
   
    // cout<<t<<" "<<a<<endl;
    
  }
  cout<<t+a<<endl;
  return 0;
}


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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        //Solve();
        return;
    }

    public static string Solve()
    {
        string S = Read();
        string T = Read();
        for (int i = 0; i < S.Length; i++)
        {
            if (S[i] != T[i])
            {
                return "No";
            }
        }
        return "Yes";
    }

    public static int Gcd(int a, int b)
    {
        if (a < b)
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 25788
import java.util.*;
import java.io.*;
import java.util.regex.*;

class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String w = br.readLine();	//キーボードで入力された１行目の文字を読み取る
        String t;
        int count = 0;
        
        while((t=br.readLine())!=null){
            if("END_OF_TEXT".equals(t) || w.length()>10 || t.length()>1000){
                break;                       //END_OF_TEXTが入力されたらwhileを抜ける
            }								 //又はwが10文字より大きいか、tの１行が1000文字より大きい場合はwhileを抜ける
            String[] str = t.split(" ");	//splitにより空白でtの１行が区切られたものをstrの配列に入れる
            for(int k=0; k<str.length; k++){
            	if(str[k].equalsIgnoreCase(w)){	//strの配列に入っているものとwを比較して
            		count++;					//同じだった場合はカウントをプラスしていく
            	}
            }
        }
        System.out.println(count);
     }
}

Measured memory_bytes: 16912
import Data.List

getlength:: String -> Int -> [Int]
getlength (s:xs) n = 
  if isInfixOf [s] "ACGT" then 
    [n] ++ getlength xs (n+1)
  else 
    [0] ++ getlength xs 1
getlength [] n = []
    


main:: IO()
main = do
  s <- getLine
  print $ maximum (getlength s 1)

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
int n,a[20],c[100],tp,ans;
int chk(){
	int ret=10007;
	for(int i=0;i<=tp;++i)
		for(int j=i+1;j<=tp;++j)
			ret=min(ret,min(abs(c[i]-c[j]),24-abs(c[i]-c[j])));
	return ret;
}
void dfs(int x){
	if(x==13){
		ans=max(ans,chk());
		return ;
	}
	if(a[x]==2)c[++tp]=x,c[++tp]=24-x,dfs(x+1),tp-=2;
	else if(a[x]==1)c[++tp]=x,dfs(x+1),c[tp]=24-x,dfs(x+1),tp--;
	else dfs(x+1);
}
int main(){
	scanf("%d",&n);
	for(int i=1,x;i<=n;++i)
		scanf("%d",&x),a[x]++;
	for(int i=0;i<=12;++i)
		if(a[i]>2)return puts("0"),0;
	dfs(0);
	printf("%d",ans);
}

Measured memory_bytes: 256
//============================================================================
// Name        : hoba.cpp
// Author      : omar  osama
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <bits/stdc++.h>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace std;
const int N = 3e5 + 5, mod = (int) 1e9 + 7;
int main() {
#ifdef ONLINE_JUDGE
    FAST;
#endif
	string s;
	cin >> s;
	int cnt = 0;
	lp(i,1,(int)s.size()-1)
		cnt += (s[i] != s[i - 1]);
	cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;

#define li long long int
#define FOR(i, a, b) for (int i = a ; i < b ; ++i)
#define REP(i, n) for (int i = 0 ; i < n ; ++i)

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

    string ans = "";
    FOR(i, 0, 3) {
        if (n[i] == '1') {
            ans += '9';
        } else {
            ans += '1';
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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 main() {
  int h,w,k;
  cin >> h >> w >> k;
  char s[h][w];
  int snum[h][w];

  FOR(i,0,h-1){
    string input;
    cin >> input;
    FOR(j,0,w-1){
      s[i][j] = input[j];
    }
  }

  int refnum = 0;

  FOR(i,0,h-1){
    bool allflat = true;
    FOR(j,0,w-1){
      if(s[i][j]=='#') allflat = false;
    }
    if(allflat){
      FOR(j,0,w-1) snum[i][j] = -1;
    }
    else{
      bool firststr = false;
      ++refnum;
      FOR(j,0,w-1){
        if(s[i][j]=='#' && firststr) ++refnum;
        else if(s[i][j]=='#' && !firststr){
          firststr = true;
        }
        snum[i][j] = refnum;
      }
    }
  }

  FOR(i,0,h-1){
    
    FOR(j,0,w-1){
      if(snum[i][j]==0) ++snum[i][j];

      if(snum[i][j]==-1){
        if(i!=0) snum[i][j] = snum[i-1][j];
      }
    }
  }

  FORD(i,h-1,0){
    FOR(j,0,w-1){
      if(snum[i][j]==-1){
        snum[i][j] = snum[i+1][j];
      }
    }
  }

  FOR(i,0,h-1){
    FOR(j,0,w-1){
      cout << snum[i][j] << " ";
    }

    cout << endl;
  }

}

Measured memory_bytes: 1152
from collections import defaultdict
def main():
    d1 = defaultdict(int)
    d2 = defaultdict(int)
    for s in input():
        d1[s] += 1
    for t in input():
        d2[t] += 1
    S = sorted(d1.values())
    T = sorted(d2.values())
    if S == T:
        print('Yes')
    else:
        print('No')
    #初期状態で異なる二文字を同一の文字に置換することはできないので、
    #変形可能な場合、Sに含まれる同一の文字の個数とTに含まれる同一の文字の個数は一致する。
if __name__ == "__main__":
    main()

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

int main(){
    int n, p;
    cin >> n >> p;
    vector<int> a(n+1);

    for(int i = 0; i < n; i++) cin >> a[i];

    vector<vector<long long int>> memo(n+1, vector<long long int>(2, 0));
    memo[0][0] = 1;
    if(a[0]%2) memo[0][1] = 1;
    else memo[0][0] += 1;
    for(int i = 1; i < n; i++){
        memo[i][0] = (a[i]%2) ? memo[i-1][1]+memo[i-1][0] : memo[i-1][0]*2;
        memo[i][1] = (a[i]%2) ? memo[i-1][0]+memo[i-1][1] : memo[i-1][1]*2;
    }

    cout << memo[n-1][p] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int b[3][3];
	int k;
	bool res = false;
	bool hit[3][3];
	for(int i=0;i<3;++i){
		for(int j=0;j<3;++j){
			cin >> b[i][j];
			hit[i][j] = false;
		}
	}
	cin >> k;
	for(int i=0;i<k;++i){
		int c;
		cin >> c;
		for(int i=0;i<3;++i){
			for(int j=0;j<3;++j){
				if(c == b[i][j])hit[i][j] = true;
			}
		}
	}
	for(int i=0;i<3;++i){
		if(hit[i][0]&&hit[i][1]&&hit[i][2]){
			res = true;
		}
		if(hit[0][i]&&hit[1][i]&&hit[2][i]){
			res = true;
		}
	}
	if(hit[0][0]&&hit[1][1]&&hit[2][2]&&true)res = true;
	if(hit[2][0]&&hit[1][1]&&hit[0][2]&&true)res = true;
	if(res)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in insert
#define mp make_pair
#define F first
#define pb push_back
#define pf push_front
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}
int main(){
    ll n,k; cin>>n>>k;
    ll a[n];
    
       ll sum=0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        if(i<k)
            sum+=a[i];
    }
    ll b[n-k+1];
    b[0]=sum;
    
    for(ll i=1;i<n-k+1;i++){
        b[i]=b[i-1]-a[i-1]+a[i+k-1];
        
    }
    for(ll i=0;i<n-k+1;i++)
        cerr<<b[i]<<" ";
    cerr<<endl;
    ll x=*max_element(b,b+n-k+1);
    cout<<fixed<<setprecision(10)<<(double)(x+k)/2;
    
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

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

bool isGood(ll x, ll k, vector<ll> &A) {
	int c = 0;
	for (int i = 0; i < (int) A.size(); i++) {
		if (A[i] <= x) continue;
		c += (A[i] / x) - (A[i] % x == 0);
	}
	return c <= k;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	vector<ll> A(n);
	ll mx = -1;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		mx = max(A[i], mx);
	}
	ll st = 1, fn = mx;
	while (st <= fn) {
		ll mid = st + (fn - st) / 2;
		if (isGood(mid, k, A)) {
			fn = mid - 1;
		} else {
			st = mid + 1;
		}
	}
	cout << st << endl;
}



Measured memory_bytes: 4740
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
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
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll h,w,k;cin>>h>>w>>k;
    vector<string>s(h);
    rep(i,h){
        cin>>s[i];
    }
    vector<vector<ll> >a(h,vector<ll>(w));
    rep(i,h){
        rep(j,w)if(s[i][j]=='1')a[i][j]++;
    }
    rep(i,h){
        REP(j,1,w){
            a[i][j]+=a[i][j-1];
        }
    }
    ll ans=inf;
    rep(i,1<<(h-1)){
        ll res=0;
        ll last=-1;
        rep(j,h){
            if((1<<j)&i)res++;
        }
        bool f=1;
            /* rep(j,h){
                if((1<<j)&i)cout<<1;
                else cout<<0;
            }
            cout<<endl;*/
        rep(j,w){
            ll ma=0;
            ll cnt=0;
            rep(l,h){
                ll d;
                if(last==-1){
                    d=0;
                }else{
                    d=a[l][last];
                }
                cnt+=a[l][j]-d;
                ma=max(cnt,ma);
                if((1<<l)&i)cnt=0;
            }
            ma=max(ma,cnt);
            //cout<<j<<' '<<ma<<endl;
            if(ma>k){
                if(last+1==j){
                    f=0;break;
                }
                else{
                    last=j-1;
                    res++;
                }
            }
        }
        if(f){
            //cout<<' '<<res<<endl;
            ans=min(ans,res);
        }
    }
    cout<<ans<<endl;
}

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

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

long long MOD = 10000000000 + 7;

template<typename T>
T gcd(T a, T b) {
  if(a < b) swap(a,b);
    
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(){
  cout << setprecision(10);
  ll A,B; cin >> A >> B;
  ll tmp = gcd(A,B);
  ll C = A / tmp;
  C *= B;
  cout << C << endl;
}


Measured memory_bytes: 3644
#95
#ALDS1_3_C
from collections import deque
n=int(input())
a = deque()

for i in range(n):
    c=input()
    if c == 'deleteFirst':
        a.popleft()
    elif c == 'deleteLast':
        a.pop()
    else:
        c,v = c.split()
        if c == 'insert':
            a.appendleft(v)
        else:
            try:
                a.remove(v)
            except:
                pass
print(' '.join(a))


Measured memory_bytes: 69736
import Control.Applicative
import Control.Monad
import Control.Monad.State
import Data.List
import Data.List.Split (splitOn)
import Data.Vector.Unboxed (Vector, (!), (//))
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = do
  n <- readLn
  [h, w] <- f
  solve h w <$> replicateM h getLine <*> (getLine >> getLine) >>= mapM_ putStrLn
  replicateM_ (n - 1) $ do
    putStrLn ""
    [h, w] <- f
    solve h w <$> replicateM h getLine <*> (getLine >> getLine) >>= mapM_ putStrLn
  where
    f = map read <$> words <$> getLine

solve :: Int -> Int -> [String] -> String -> [String]
solve h w ss cs = let iv = V.fromList $ replicate (w + 1) ' ' ++ intercalate " " ss ++ replicate (w + 1) ' '
                      Just ii = find (\i -> let c = iv ! i in c == '^' || c == 'v' || c == '<' || c == '>') [0..]
                      is = (fromIdx ii, iv)
                  in evalState (f cs) is
  where
    toIdx (i, j) = (i + 1) * (w + 1) + j
    fromIdx ix = let (q, r) = divMod ix (w + 1) in (q - 1, r)

    f :: String -> State ((Int, Int), Vector Char) [String]
    f [] = do
      (_, v) <- get
      return $ splitOn " " $ take (h * (w + 1) - 1) $ drop (w + 1) $ V.toList v

    f (c:cs) = do
      ((i, j), v) <- get
      case c of
       'U' -> if v ! (toIdx (i - 1, j)) == '.'
              then put ((i - 1, j), v // [(toIdx (i - 1, j), '^'),(toIdx (i, j), '.')])
              else put ((i, j), v // [(toIdx (i, j), '^')])
       'D' -> if v ! (toIdx (i + 1, j)) == '.'
              then put ((i + 1, j), v // [(toIdx (i + 1, j), 'v'),(toIdx (i, j), '.')])
              else put ((i, j), v // [(toIdx (i, j), 'v')])
       'L' -> if v ! (toIdx (i, j - 1)) == '.'
              then put ((i, j - 1), v // [(toIdx (i, j - 1), '<'),(toIdx (i, j), '.')])
              else put ((i, j), v // [(toIdx (i, j), '<')])
       'R' -> if v ! (toIdx (i, j + 1)) == '.'
              then put ((i, j + 1), v // [(toIdx (i, j + 1), '>'),(toIdx (i, j), '.')])
              else put ((i, j), v // [(toIdx (i, j), '>')])
       'S' -> let ixs = case v ! (toIdx (i, j)) of
                    '^' -> zip [i-1, i-2 .. 0] (repeat j)
                    'v' -> zip [i+1 .. h-1] (repeat j)
                    '<' -> zip (repeat i) [j-1, j-2 .. 0]
                    '>' -> zip (repeat i) [j+1 .. w-1]
              in case find (\(x,y) -> let c = v ! (toIdx (x, y)) in c == '*' || c == '#') ixs of
                  Nothing -> put ((i, j), v)
                  Just (x, y) -> if v ! (toIdx (x, y)) == '*'
                                 then put ((i, j), v // [(toIdx (x, y), '.')])
                                 else put ((i, j), v)
      f cs



Measured memory_bytes: 4752
#include <stdio.h>

int main(void)
{
	int a,b,n;
	
	scanf("%d %d %d",&n,&a,&b);
	
	if(a*n>=b){
		printf("%d\n",b);
	}else{
		printf("%d\n",a*n);
	}
	
	return 0;
}

Measured memory_bytes: 128
#python3
def main():
    n, m = map(int, input().split())
    a = [int(i) for i in input().split()]
    s = sum(a)
    c = 0
    for i in range(n):
        if a[i] < (s+4*m-1)//(4*m):
            c += 1
    ans = n - c
    print('Yes') if ans >= m else print('No')
main()

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long int ll;

ll dp[110][11000];

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


Measured memory_bytes: 11320
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        ll ans = 1;
        rep(i, 1, N+1) {
                ans = ans * i % mod;
        }
        cout << ans << endl;
}

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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

using ll = long long;
using pii = pair<int, int>;

void solve() {
    int n;
    string s;
    cin >> n >> s;
    cout << (~n & 1 && s.substr(0, n / 2) == s.substr(n / 2) ?
            "Yes" : "No");
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


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

ll solve() {
    vector<ll> 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 k;
    cin >> k;
    cout << a[k-1] << "\n";    
    
    return 0;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

void
solve() {
  int x, y;
  cin>>x>>y;

  if (y <= 4 * x && y >= 2 * x && y % 2 == 0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

}

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

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ll X;
    cin >> X;
    cout << 10 - X / 200 << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
bool is_prime(lli x) {
  for(lli i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}
int main() {
  lli A,B,C=0,D=0,E=0,F=0,G=0,H=0,N,M;
  cin >> A >> B;
  if(A*B==15)Out('*');
  else if(A+B==15)Out('+');
  else Out('x');
}


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#define INFILE freopen("input.txt", "r", stdin)
#else
#define debug(x)
#define INFILE
#endif

#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll INF = 1LL << 60;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

struct Node {
  vector<int> children;
  ll cost;
  bool used;
};

Node nodes[200010];
ll results[200010];

int main(int argc, char* argv[]) {
  ll N, Q;
  cin >> N >> Q;

  REP(i, 0, N - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    nodes[a].children.push_back(b);
    nodes[b].children.push_back(a);
  }

  REP(i, 0, Q) {
    int p, x;
    cin >> p >> x;
    p--;
    nodes[p].cost += x;
  }

  stack<int> s;
  s.push(0);

  ll cost = 0;
  while (!s.empty()) {
    int index = s.top();
    s.pop();

    if (nodes[index].used) {
      cost -= nodes[index].cost;
      continue;
    }

    cost += nodes[index].cost;
    results[index] = cost;
    nodes[index].used = true;

    s.push(index);
    for (int next : nodes[index].children) {
      if (nodes[next].used) continue;
      s.push(next);
    }
  }

  string result;
  REP(i, 0, N) { result += to_string(results[i]) + " "; }
  result.pop_back();
  cout << result << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 21748
/*    *** Bismillahir Rahmanir Rahim***
          *A S M Masud Parvez*
             *18ICTCSE035*
           *SHIICT(BSMRSTU)*
*/
#include<bits/stdc++.h>
using namespace std;
#define MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define      for0(i,n) for(int i=0;i<n;i++)
#define      for1(i,n) for(int i=1;i<n;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      nl   "\n"
#define      End  return 0
#define      gt   greater<int>()
#define      ll   long long int
#define      mp   make_pair
#define      pb   push_back
#define      vi   vector<int>
#define      vl   vector<ll>
#define      mod  1000000007
#define      ull  unsigned long long int
int          Max = INT_MIN,Min = INT_MAX;
#define      sp(n) fixed<<setprecision(n)
#define      pi acos(-1)
int main()
{
MP;
int n;
string s;
cin>>s;
n=s.size();
int x=s[n-1];
if(x=='2'||x=='4'||x=='5'||x=='7'||x=='9'){
  cout<<"hon";
}
else if(x=='0'||x=='1'||x=='6'||x=='8'){
  cout<<"pon";
}
else if(x=='3'){
  cout<<"bon";
}


End;
}


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

int main(){
    ll h,w;
    cin >> h >> w;
    ll ans;
    if(h == 1 || w == 1){
        cout << 1 << endl;
    } else {
        cout << (h*w+1)/2 << endl;
    }


}


Measured memory_bytes: 256
import math
a,b = map(int,input().split(" "))
def gcd(a,b):
    if a < b:
        a,b = b,a
    while b > 0:
        a,b = b, a % b
    return a


def factorize(num):
    res = list()
    n = num
    while num % 2 == 0:
        num //= 2
        res.append(2)

    for i in range(3,int(math.sqrt(n))):
        while num % i == 0:
            num //= i
            res.append(i)
    
    if num >= 2:
        res.append(num)
    return res
    

g = gcd(a,b)
print(len(set(factorize(g))) + 1)



Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		int p = B/A;
		
		System.out.println(Math.min(p,C));
		sc.close();
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define int long long

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

    int n,r;
    cin>>n>>r;

    int ans;

    if(n>=10)
        ans = r;
    else{
        ans = r + 100 * (10 - n);
    }

    cout << ans << endl;
}


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

int main(){
    string s,t;
    int q;
    cin>>s>>q;
    deque<char> d;
    for(int i=0;i<s.length();i++) d.push_back(s[i]);
    bool flag=false;
    for(int i=0;i<q;i++){
        int n; cin>>n;
        if(n==1){
            flag=!flag;
        }else{
            int f;
            char c;
            cin>>f>>c;
            if(flag) f=(f==1?2:1);
            if(f==1) d.push_front(c);
            else d.push_back(c);
        }
    }
    if(flag) reverse(d.begin(),d.end());
    for(char c:d) cout<<c;
    cout<<endl;
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void){
    long n;
    long num[200000];
    long i;
    long max = -2000000000;
	long min;

    scanf("%ld", &n);
    for(i=0; i<n; i++){
        scanf("%ld", &num[i]);
    }
    min = num[0];

    for(i=1; i<n; i++){
        if(max < num[i] - min) max = num[i] - min;
        if(num[i] < min) min = num[i];
    }

    printf("%ld\n", max);
	return 0;
}

Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    string s;
    cin >> s;
    cout << string(s.size(), 'x') << endl;

    return 0;
}

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

using namespace std;


int a,b,c;
int cnt = 1;

int main (){
	cin >> a >> b >> c;
	if (a == b || b == c){
		cout << "NO";
		return 0;
	}
	while (cnt != a * b *c){
		if (cnt % a == 0 && cnt % b == c){
			cout <<  "YES";
			return 0;
		}	
		else {
			cnt++;
		}
	}
	cout << "NO";
	return 0;
}

Measured memory_bytes: 256
from math import gcd

N, M = [int(x) for x in input().split()]
S = input()
T = input()

lcm = N * M // gcd(N, M)
count = 1

result = -1


def check(answer_length, line, answer):
    for i in range(0, len(line)):
        idx = i * answer_length // len(line) + 1

        if idx in answer:
            if not answer[idx] == line[i]:
                return False
        else:
            if idx <= answer_length:
                answer[idx] = line[i]
            else:
                return False

    return True


answer = {}
max_str = max((M-1) * (lcm * count) // M + 1,
                  (N-1) * (lcm * count) // N + 1)

if check(lcm * count, S, answer):
    if check(lcm*count, T, answer):
        print(lcm*count)
        exit()

print(result)


Measured memory_bytes: 21600
#include "bits/stdc++.h"

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

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


signed main(){

	int N, M;
	cin >> N >> M;
	int d[100][100];

	for (int i = 0; i < 100; i++)
		for (int j = 0; j < 100; j++){
			d[i][j] = INF;
		}

	int a[1000], b[1000], c[1000];
	for (int i = 0; i < M; i++){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--;
		d[a[i]][b[i]] = c[i];
		d[b[i]][a[i]] = c[i];
	}

	for (int k = 0; k < N; k++){
		for (int i = 0; i < N; i++){
			for (int j = 0; j < N; j++){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < M; i++){
		if (c[i] > d[a[i]][b[i]]){
			ans++;
		}
	}

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
#define N 300000

int main()
{
  int n;
  long long k;
  int a[N],b[N]={0};

  cin >> n >> k;

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

  int r=1,count1=0;
  while(b[r]==0){
    b[r]=1;
    r=a[r];
    count1++;
  }

  int s=1,count2=0;
  while(s!=r){
    s=a[s];
    count2++;
  }

  int ans;
  if(k<count2){
    ans=1;
    for(int i=0; i<k; i++){
      ans=a[ans];
    }
  }
  else{
    ans=r;
    for(int i=0; i<(k-count2)%(count1-count2); i++){
     ans=a[ans];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5544
#include <iostream>
#include <map>

int main()
{
  int N, M;
  std::cin >> N >> M;
  std::map<int, int> m;
  for ( int i = 0; i < 2*M; i++ ) {
    int tmp;
    std::cin >> tmp;
    m[tmp]++;
  }
  for ( int i = 1; i <= N; i++ ) {
    std::cout << m[i] << std::endl;
  }
  return 0;
}


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

int main(){
    long long N;
    cin >> N;
    long long A[N+1];
    long long i;
    for(i=1; i<=N; i++){
        cin >> A[i];
    }
    long long A_MAX=A[1];
    long long val=0;
    for(i=2; i<=N; i++){
        if(A[i]<=A_MAX){
            val+=A_MAX-A[i];
        }else{
            A_MAX=A[i];
        }
    }
    cout << val << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 5244
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;

const ll MX = 1e18;

int main(){
    int n;
    ll ans=1;
    cin >> n;
    bool ng = false;
    rep(i, n) {
        ll a;
        cin >> a;
        if (a == 0){
            cout << 0 << endl;
            return 0;
        }
        if(ng || MX/ans < a){
            ng = true;
        }
        ans *= a;
    }
    if(ng) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		boolean flag = true;
		while (flag == true) {
			int nico = Integer.parseInt(sc.nextLine());
			if (nico == 0) break;

			int max = -5000 * 100000;
			int[][] a = new int[nico][nico];
			for (int i = 0; i < nico; i++) {
				a[0][i] = Integer.parseInt(sc.nextLine());
				if (max < a[0][i]) max = a[0][i];
			}
			
			for (int i = 1; i < nico; i++) {
				for (int j = 0; j < (nico - i); j++) {
					a[i][j] = a[i-1][j] + a[0][i+j];
					if (max < a[i][j]) max = a[i][j];
				}
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 83204
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    string s;cin>>s;
    if(s[0]==s[1] && s[1]==s[2]) cout<<"Yes"<<endl;
    else if(s[1]==s[2] && s[3]==s[2]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c;
    cin >> a >> b >>c;
    if(b/a>=c){
        cout << c;
    }
    else{
        cout << b/a ;
    }


    return 0;
}

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


int GCD(int a, int b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
int main() {
  int a,b,k;
  cin >> a >> b >> k;
  int big = GCD(a,b);
  int count = 0;
  for (int i = 1; i <= big; i++) {
    if (big%i == 0) {
      count++;
      if (count == k) {
        cout << big/i << endl;
      }
    }
  }
  
  
}

Measured memory_bytes: 256
using System;

namespace ABC046B{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<long>();
            var K = sr.Next<long>();
            Console.WriteLine(K * Math.Pow(K - 1, N - 1));
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];
        private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = _sr.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;

int main(){
	int k, x;
  	cin >> k >> x;
  
  	if(500 * k >= x) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 256