akhauriyash/Code-Regression huggingface dataset:
void main()
{
    long[] tmp = rdRow;
    long n = tmp[0], m = tmp[1];
    string s = rdStr;
    string t = rdStr;

    long g = gcd(n, m);
    long l = n * m / g;
    long sl = n / g, tl = m / g;
    foreach (i; 0 .. g)
    {
        if (s[sl*i] != t[tl*i])
        {
            writeln(-1);
            return;
        }
    }
    l.writeln;
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 2428
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class E { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long H = GetLong();
		long W = GetLong();
		long M = GetLong();
		var h = new long[M];
		var w = new long[M];
		var R = new long[H];
		var C = new long[W];
		for(long i = 0; i < M; i++)
		{
			h[i] = GetLong() - 1;
			w[i] = GetLong() - 1;
			R[h[i]]++;
			C[w[i]]++;
		}

		var RMax = R.Max();
		var CMax = C.Max();
		long cnt = R.Count(x => x == RMax) * C.Count(x => x == CMax);
		for(long i = 0; i < M; i++)
		{
			if(R[h[i]] == RMax && C[w[i]] == CMax)
				cnt--;
		}

		WriteLine(cnt == 0 ? RMax + CMax - 1 : RMax + CMax);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

int main(void){
    int X,N;
    cin >> X >> N;
    int p[N+10];
    for(int i=0;i<N;i++){
        int s;
        cin >> p[i];
    }
    int min = 110;
    int p_temp;
    for(int i=0;i<=100;i++){
        int p_temp_min = X + (-1) * i;
        int p_temp_plus = X + i;
        bool can1 = true;
        bool can2 = true;
        for(int j=0;j<N;j++){
            if(p[j] == p_temp_min){
                can1 = false;
            }
            if(p[j] == p_temp_plus){
                can2 = false;
            }
        }
        if(can1) {
            p_temp = p_temp_min;
            break;
        }
        if(can2){
            p_temp = p_temp_plus;
            break;
        }
    }
    cout << p_temp << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

struct items{
    ll num, count;
};

bool asc( const items& left, const items& right ) {
    return left.num == right.num ? left.count < right.count : left.num > right.num;
}
int main() {
    

    ll n,m;
    map <ll,ll> v;
    cin >> n >> m;
    for (ll i=0;i<n;i++){
        ll tmp;
        cin >> tmp;
        v[tmp]++;
    }
    for (ll i=0;i<m;i++){
        ll p,q;
        cin >> p >> q;
        v[q] += p;
    }
//    reverse(v.begin(), v.end());
    ll ans = 0;
    deque <items> itemList;
    for (auto itr = v.begin(); itr != v.end(); itr++){
        items p;
        p.num = itr -> first;
        p.count = itr -> second;
        itemList.push_back(p);
    }
    sort(itemList.begin(), itemList.end(), asc);
    while (n > 0){
        if(itemList.front().count > 0){
            ans += itemList.front().num;
//            cout << itemList.front().num << endl;
            itemList.front().count--;
        }else{
            itemList.pop_front();
            continue;
        }
        n--;
    }
    cout << ans << endl;



}

Measured memory_bytes: 16000
import math

DP_MAX = 2*10**4 + 1
INF = 2*10**8

H,N = map(int,input().split())
M = [0]*N
for _ in range(N):
    M[_] = tuple(map(int,input().split()))

DP = [0]+[INF]*(DP_MAX - 1)

for A,B in M:
    for j in range(1,DP_MAX):
        if j - A >= 0:
            DP[j] = min(DP[j],DP[j - A]+B)

print(min(DP[H:]))

Measured memory_bytes: 42348
A=list(map(int,input().split()))
A.sort()

ans=0

ans+=A[2]-A[1]
A[0]+=A[2]-A[1]
A[1]+=A[2]-A[1]
#print(A)

ans+=(A[1]-A[0])//2+((A[1]-A[0])%2)*2
print(ans)

Measured memory_bytes: 3064
import sys
N,M = map(int, input().split())
A = [tuple(input().split()) for _ in range(M)]
a_cnt = 0
p_cnt = 0
wa = [0] * N
flg = [0] * N

for i in range(M):
  no = int(A[i][0])-1
  if A[i][1] == "AC" and flg[no] == 0:
    a_cnt += 1
    p_cnt += wa[no]
    flg[no] = 1
    continue
  else:
    wa[no] += 1
print(a_cnt, p_cnt)
    

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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  // ll ans;
  // if(n < a + b)
  //   ans = min(n, a);
  // else {
  //   ans = n / (a + b) * a;
  //   if(n % (a + b) != 0)
  //     ans += min(a, n - a - b);
  // }
  ll ans = n / (a + b) * a;
  ll rem = n % (a + b);
  ans += min(a, rem);
  cout << ans;
}


Measured memory_bytes: 3608
fn read_nums() -> Vec<i32> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf);
  buf.split_whitespace().map(|x| x.parse::<i32>().unwrap()).collect()
}

fn main() {
  let nums = read_nums();
  let a = nums[0];
  let b = nums[1];
  let mut r = 0;
  if a == b {
    r = a * 2;
  } else if a > b {
    r = a * 2 - 1;
  } else {
    r = b * 2 - 1;
  }
  println!("{}", r);
}

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

int main() {
  int N, A, count;
  count = 0;
  cin >> N;
  A=2;
  while (A<N) {
    count+=N/A+1;
    if(N%A==0) {
      count-=1;
    }
    A++;
  }
  
  
  
  
  cout << count + 1 << endl;
}




Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n;
    cin >> n;
    Vi t(n),v(n);
    ll time=0;
    rp(i,n) {
        cin >> t[i];
        time+=t[i];
    }
    rp(i,n) cin >> v[i];
    Vi speed(2*(time+2));
    rp(i,2*time+1){
        speed[i]=min(i,2*time-i);
    }
    ll t_sum=0;
    rp(i,n){
        ll st=t_sum,en=t_sum+t[i];
        t_sum+=t[i];
        rp(j,2*time+1){
            if(j<2*st) chmin(speed[j],2*v[i]+2*st-j);
            else if(j>2*en) chmin(speed[j],2*v[i]+j-2*en);
            else chmin(speed[j],2*v[i]);
        }
    }
    double dist=0.0;
    rp(i,2*time){
        dist+=(double)(speed[i]+speed[i+1])/2.0;
    }
    print(dist/4.0);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3852
N,M=sorted(map(int,input().split()))

if N==1:
    if M==1:
        print(1)
    elif M==2:
        print(0)
    elif M>=3:
        print(M-2)

elif N==2:
    if M==2:
        print(0)
    elif M>=3:
        print(0)

else:
    print((N-2)*(M-2))



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

int main(){
  int A , B , C ; 
  cin >> A >> B >> C ; 
  int K  ;
  cin >> K ; 
  
  int N = max(A , max(B , C)) ; 
  cout << pow(2 , K) * N + min(A+B , min(A+C , B+C)) << endl  ; 
  
}

Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define pbb pop_back
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
const int m=1e9+7;
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s1,s2;
    cin>>s1>>s2;
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    if(s==s1)
    cout<<a-1<<" "<<b<<endl;
    else
    cout<<a<<" "<<b-1<<endl;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int dp[101][2][5];

int main() {
    string n;
    int k, l;
    cin >> n >> k;
    l = n.size();
    dp[0][0][0] = 1;
    for (int i = 0; i < l; ++i) {
        for (int cnt = 0; cnt <= k; ++cnt) {
            if (n[i] == '0')  {
                dp[i + 1][0][cnt] += dp[i][0][cnt]; // 0
            }
            else {
                dp[i + 1][1][cnt] += dp[i][0][cnt]; // 0
                dp[i + 1][1][cnt + 1] += dp[i][0][cnt] * (n[i] - '0' - 1); // 1 ~ n[i]
                dp[i + 1][0][cnt + 1] += dp[i][0][cnt]; // n[i]
            }
            dp[i + 1][1][cnt] += dp[i][1][cnt]; // 0
            dp[i + 1][1][cnt + 1] += dp[i][1][cnt] * 9;
        }
    }
    cout << dp[l][0][k] + dp[l][1][k] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{

int S,h,m,s;

scanf("%d",&S);

s = ( S % 3600) % 60;

m = (( S % 3600) - s ) / 60;

h = ( S - ( m * 60 - s )) /  3600;

printf("%d:%d:%d\n",h,m,s );

return 0;

}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef pair<ll, ll> pll;

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

vector<vector<int>> graph;
vector<vector<int>> que;
int distances[2001][2001];

void bfs(int N, int start) {
  vector<int> newball;  
  bool seen[N+1];
  memset(seen, 0, sizeof(seen));
  seen[start] = true;

  int count = 0;
  while (que.size() > 0) {
    count++;
    vector<int> points = que.back();
    que.pop_back();

    newball.clear();
    for(auto p: points) {
      if (seen[p]) continue;
      else {
        distances[start][p] = count;
        seen[p] = true;
        for (auto v: graph[p]) newball.push_back(v);
      }
    }
    if (newball.size() >0) que.insert(que.begin(), newball);
  }

}

int main() {
    // input, ready
    int N,X,Y;
    cin >> N >> X >> Y;
    graph.resize(N+1);
    vector<int> vec;
    for (int i=1; i<=N; i++) {
      vec.clear();
      if (i != N) vec.push_back(i+1);
      if (i != 1) vec.push_back(i-1);
      if (i == X) vec.push_back(Y);
      if (i == Y) vec.push_back(X);
      graph[i] = vec;
    }    

    // resolve
    for (int i=1; i<N+1; i++) {
      memset(distances, 0, sizeof(0));
      que.push_back(graph[i]);
      bfs(N, i);
    }

    map<int,int> ans;
    for(int i=1; i<N; i++) {
      for(int j=i+1; j<N+1; j++) {
        ans[distances[i][j]]++;
      }
    }

    // output
    int cnt=1;
    for(auto a: ans) {
      cout << a.second << endl;
      cnt++;
    }
    for (int i =cnt; i<N; i++) cout << 0 << endl;

    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> X(N);
    rep(i, N) cin >> X[i];
    vector<vector<ll>> cnt(M);
    rep(i, N) {
        cnt[X[i] % M].push_back(X[i]);
    }
    ll ans = 0;
    ans += cnt[0].size() / 2;
    if (M % 2 == 0) ans += cnt[M / 2].size() / 2;
    rep2(i, 1, (M + 1) / 2) {
        vector<ll> S = cnt[i];
        vector<ll> T = cnt[M - i];
        if (S.size() >= T.size()) {
            T = cnt[i];
            S = cnt[M - i];
        }
        ll over = T.size() - S.size();
        ans += S.size();

        map<ll, ll> C;
        for (ll t : T) {
            C[t]++;
        }
        ll tmp = 0;
        for (P c : C) {
            tmp += c.second / 2;
        }
        ans += min(over / 2, tmp);
    }
    cout << ans << '\n';
}


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 6528
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
///////////////////////___combination___////////////////////
vector<ll> fac, finv, inv;
void COMinit(const int MAX = 5000000, const ll &MOD = MOD){
  fac.resize(MAX);finv.resize(MAX);inv.resize(MAX);
  fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
  repd(i,2,MAX){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
ll COM(int n, int k){
  if(n < k)return 0;
  if(n < 0 || k < 0)return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

///////////////////////////////////////////////////////////

int n;
signed main(){
  cin>>n;int ans = 0;
  queue<int> que;
  que.push(3);que.push(5);que.push(7);
  while(que.front() <= n){
    int p = que.front();que.pop();
    que.push(p*10+3);
    que.push(p*10+5);
    que.push(p*10+7);
    bool b[10];rep(i,10)b[i] = false;
    while(p > 0){
      b[p%10] = true;
      p /= 10;
    }
    if(b[3] && b[5] && b[7])ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 768
#include <cstdio>
#include<iostream>
char s[100][100];
int c[100][100],a,b,ans,cnt;
int d[2][2]={1,0,0,1};
void bfs(int x,int y)
{
   if((x==a-1)&&(y==b-1)) {ans=1;return ;}
   for(int i=0;i<2;i++)
    {
        int dx=x+d[i][0];
        int dy=y+d[i][1];
        if(s[dx][dy]=='#'&&dx>=0&&dx<a&&dy>=0&&dy<=b)
        bfs(dx,dy);
    }
}
int main()
{
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        for(int i=0;i<a;i++)
         {
             scanf("%s",s[i]);
             for(int j=0;j<b;j++)
                if(s[i][j]=='#') cnt++;
         }
         ans=0;
         bfs(0,0);
         if(ans==1 && cnt==a+b-1) printf("Possible\n");
         else printf("Impossible\n");

    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream> 
#include<algorithm>
using namespace std;
int A,B;
int main(){
//	#ifndef ONLINE_JUDGE
//	freopen("A.in","r",stdin);
//	freopen("A.out","w",stdout);
//	#endif
	cin>>A>>B;
	printf("%d",max(A+B,max(A*B,A-B)));
	return 0;
} 

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

int main() {
    long n, p;
    cin >> n >> p;

    if (n == 1) {
        cout << p << endl;
        return 0;
    }

    long ans = 1;
    long double s = pow(p, 1.0 / n);

    for (long i = 2; i <= s + 1; i++) {
        if (p % i > 0) {
            continue;
        }

        long ss = 1;
        for (long j = 0; j < n; j++) {
            ss *= i;
            if (ss > p) {
                break;
            }
        }

        if (p - ss < 0) {
            continue;
        }

        if (p % ss == 0) {
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef DEBBY
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define ll long long
#define rep(i,a,b) for(int i=int(a); i<=int(b); i++)
#define sz(v)  (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define fs first
#define sd second
#define pb push_back


void solve(){
   int n; cin >> n; vi v(n); 
   rep(i,0,n-1){
     cin >> v[i];
   }
   bool flag = false;
   int next=-1;
   for(int i=0; i<n;i++){
     if(v[i]!=i+1 && next!=i+1){
       if(flag || v[v[i]-1]!=i+1){
          cout << "NO"; return;
       } else {
          flag = true;
          next = v[i];
       }
     }
   }
   cout << "YES";
} 

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}
    





Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll x, y;

int main(void)
{
	cin>>x>>y;
	if(abs(x-y)<=1) cout<<"Brown";
	else cout<<"Alice";
	return 0;
}
// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <math.h>
using namespace std;

#define ll long long

int main(){
    int N,ans = 0,BA = 0;
    cin >> N;
    int count[N] = {},headb[N] = {},enda[N] = {};
    string s[N];
    for(int i = 0;i < N;i++){
        cin >> s[i];
        if(s[i][0] == 'B')headb[i] = 1;
        if(s[i][s[i].length() - 1] == 'A')enda[i] = 1;
        if(headb[i] && enda[i])BA++;
        for(int j = 0;j < s[i].length() - 1;j++){
            if(s[i][j] == 'A' && s[i][j+1] == 'B')count[i]++;
        }
    }
    for(int i = 1;i < N;i++){
        headb[0] += headb[i];
        enda[0] += enda[i];
        count[0] += count[i];
    }
    ans = count[0] + (headb[0] > enda[0] ? enda[0] : headb[0]);
    if(BA && BA == headb[0] && BA == enda[0])ans--;
    cout << ans << endl;
    return 0;
}

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

int main() {
long long int ans = 0;
 long long int N;
  cin >> N;
  if(N == 1)
    cout << 0 << endl;
  else
    cout << N*(N+1)/2 - N << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int t;
    while(cin >> t, t){
        int n;
        cin >> n;
        for (int i = 0; i < n; ++i) {
            int a, b;
            cin >> a >> b;
            t -= b-a;
        }
        if(t <= 0) puts("OK");
        else cout << t << "\n";
    }
    return 0;
}


Measured memory_bytes: 3052
#include<algorithm>
#include<chrono>
#include<climits>
#include<functional>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
// #include<bits/stdc++.h>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
 
typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

const int MAXN = 1e5 + 20, MAXM = 1e3 + 5;
// int N = 1 << 12;
int dp[(1 << 12)], tmp[(1 << 12)];
int a[MAXM], b, c, comb[MAXM];

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;
 	
 	int n, m;
    cin >> n >> m;
    int N = 1 << n;
    for(int i = 0; i < m; i++) {
    	cin >> a[i] >> b;
    	comb[i] = 0;
    	for(int j = 0; j < b; j++) {
    		cin >> c;
    		c--;
    		comb[i] |= (1 << c);
    	}
    }

    fill(dp, dp + N, 2e9);
    fill(tmp, tmp + N, 2e9);
    dp[0] = 0;
    for(int i = 0; i < m; i++) {
    	for(int mask = 0; mask < N; mask++){
    		if(dp[mask] == 2e9) continue;
    		tmp[mask | comb[i]] = min(tmp[mask | comb[i]], dp[mask] + a[i]);
    	}
    	for(int mask = 0; mask < N; mask++) {
    		dp[mask] = min(dp[mask], tmp[mask]);
    		tmp[mask] = 2e9;
    	}
    }
    cout << (dp[N - 1] == 2e9 ? -1 : dp[N - 1]) << endl;


    return 0;
}























Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vi vector<int>

int main(){


  int n;
  cin>>n;
  
  map<string,int> data;
  
  rep(i,n){
    string tmp;
    cin>>tmp;
    if (data.count(tmp)){
      data.at(tmp)++;
    }
    else {
      data[tmp]=1;
    }
  }
  
  int maxcount=0;
  
  for (auto mypair:data){
    maxcount=max(maxcount,mypair.second);
  }
  
  vector<string> answer;
  for (auto mypair:data){
    if (mypair.second==maxcount){
      answer.push_back(mypair.first);
    }
  }
  
  sort(answer.begin(),answer.end());
  
  for (auto mystring:answer){
    cout<<mystring<<endl;
  }
  
  
  
}



Measured memory_bytes: 26868
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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(){
  ll n, m, q;
  cin >> n >> m >> q;
  ll ans = 0;
  vi a(q);
  vi b(q);
  vi c(q);
  vi d(q);
  rep(i,q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  vi x(10, 1);
  for (ll i = 1; i <= m;i++){
    x[0] = i;
    for (ll j = i; j <= m; j++){
      x[1] = j;
        for (ll k = j; k <= m;k++){
          x[2] = k;
            for (ll l = k; l <= m;l++){
              x[3] = l;
                for (ll o = l; o <= m;o++){
                  x[4] = o;
                    for (ll p = o; p <= m;p++){
                      x[5] = p;
                        for (ll r = p; r <= m;r++){
                          x[6]=r;
                            for (ll s = r; s <= m;s++){
                              x[7] = s;
                              for (ll t = s; t <= m; t++){
                                x[8] = t;
                                for (ll u = t; u <= m; u++){
                                  x[9] = u;
                                  ll total = 0;
                                  rep(v, q){
                                    if (x[b[v]-1] - x[a[v]-1] ==c[v]){
                                      total +=d[v];
                                    }
                                  }
                                  ans = max(ans, total);
                                }
                              }
                            }
                        }                     
                    }
             }            
          }
       }
    }
  }
  print(ans);
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll H, W;
    cin >> H >> W;
    vector<ll> c(100);
    rep(i, 100) cin >> c[i];
    vector<ll> A(H * W);
    rep(i, H * W) cin >> A[i];
    
    
    // Warshall–Floyd 
    ll INF = 1e18;
    vector<vector<ll> > d(10, vector<ll>(10, INF));
    rep(i, c.size()) {
        int a = i / 10;
        int b = i % 10;
        d[a][b] = c[i];
    }
    ll n = 10;
    rep(k, n) {
        rep (i, n) {
            rep (j, n) {
                if (d[i][k] < INF && d[k][j] < INF) {
                    d[i][j] = min(
                        d[i][j], d[i][k] + d[k][j]);
                }
            }
        }        
    }

    ll res = 0;
    rep(i, A.size()) {
        if (A[i] >= 0) {
            res += d[A[i]][1];
        }
    }
    
    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

const int N = 3000;
ll dp[N][N];
int n , m;
string s , w;

ll calc (int i , int j){

    if (i == n || j == m)
        return 0;

    ll &ret = dp[i][j];
    if (~ret)
        return ret;

    if (s[i] == w[j])
        ret = calc(i+1,j+1) + 1;
    else
        ret = max (calc(i+1,j) ,  calc(i,j+1));

    return ret;

} 

void display (int i , int j){

    if (i == n || j == m)
        return;

    if (s[i] == w[j]){
        cout << s[i];
        display(i+1,j+1);
        return;
    }

    if (calc(i,j) == calc(i+1,j))
        display(i+1,j);
    else
        display(i,j+1);

}

void Suhaib_Sawalha (){

    cin >> s >> w;
    n = s.size();
    m = w.size();

    memset(dp,-1,sizeof dp);
    calc(0,0);
    display(0,0);

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 74180
import Foundation

func readInt() -> [Int] {
    return readLine()!.split(separator: " ").map { c in Int(c)! }
}

func main() {
    let S = readLine()!

    var x = 0
    var pow10 = 1
    var counts = Array(repeating: 0, count:2019)
    counts[0] = 1
    for c in S.reversed() {
        x += Int(String(c))! * pow10
        pow10 *= 10
        x %= 2019
        pow10 %= 2019
        counts[x] += 1
    }
    let ans = counts.reduce(0) {$0 + $1 * ($1 - 1) / 2}

    print(ans)
}


main()

Measured memory_bytes: 13380
#include<stdio.h>
#define N 100

void print(int a[],int n){
	for(int i=0;i<n-1;i++)
		printf("%d ",a[i]);
		
	printf("%d\n",a[n-1]);
	
	return;
}


void insertionSort(int a[],int n){
	int i,j;
	
	for(i=0;i<n;i++){
		int t=a[i];
		j=i-1;
		while(j>=0 && a[j] > t){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=t;
		print(a,n);
	}
	
	return;
}


int main(){
	int n,i;
	int a[N];
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	
	insertionSort(a,n);
	
	return 0;
	
}


Measured memory_bytes: 2144
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> data(H + 2);
    string emp = "";
    rep(i, W + 2)
    {
        emp.push_back('.');
    }
    data.at(0) = emp;
    data.at(H + 1) = emp;
    rep2(i, 1, H + 1)
    {
        string input = "";
        cin >> input;
        data.at(i) = '.' + input + '.';
    }
    rep2(i, 1, H + 1)
    {
        rep2(j, 1, W + 1)
        {
            if (data.at(i).at(j) == '#')
            {
                if (data.at(i).at(j - 1) != '#' && data.at(i + 1).at(j) != '#' && data.at(i).at(j + 1) != '#' && data.at(i - 1).at(j) != '#')
                {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int N;
  lint ans=0;
  cin >> N;
  
  unordered_map<string,int> S;
  
  rep(i,N){
    string s;
    cin >> s;
    sort(all(s));
    
    auto itr = S.find(s);
    if( itr != S.end() ) {
        ans+=S[s];
        S[s]+=1;
    } else {
        S[s]=1;
    }
    
  }
  
  cout << ans << endl; 
  
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   int x;
   cin>>x;
   if(x>=30) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 3620
package main

import "fmt"

func reverseString(s string) string {
	rs := []rune(s)
	for i, j := 0, len(rs)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	var ans int
	for i := a; i <= b; i++ {
		s := fmt.Sprintf("%d", i)
		rs := reverseString(s)
		if s == rs {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v;
    for(int i = 0; i <= 200000; i++){
        v.push_back(0);
    }
    for(int i = 0; i < n; i++){
        int in;
        cin >> in;
        v[in]++;
    }
    sort(v.begin(), v.end(), greater<int>());
    int ans = n;
    for(int i = 0; i < k; i++){
        ans -= v[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
# -*- coding: utf-8 -*-
"""
E - Travel by Car
https://atcoder.jp/contests/abc143/tasks/abc143_e

"""
import sys


from scipy.sparse.csgraph import floyd_warshall

def main(args):
    N, M, L = map(int, input().split())
    g1 = [[float('inf')] * (N+1) for _ in range(N+1)]
    for i in range(N+1):
        g1[i][i] = 0
    for _ in range(M):
        A, B, C = map(int, input().split())
        g1[A][B] = g1[B][A] = C
    d1 = floyd_warshall(g1)
    g2 = [[float('inf')] * (N+1) for _ in range(N+1)]
    for i in range(N+1):
        for j in range(N+1):
            if i == j:
                g2[i][j] = 0
            elif d1[i][j] <= L:
                g2[i][j] = g2[j][i] = 1
    d2 = floyd_warshall(g2)
    Q = int(input())
    for _ in range(Q):
        s, t = map(int, input().split())
        print(-1 if d2[s][t] == float('inf') else int(d2[s][t]) - 1)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 19372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;

ll func(ll N){
    if(N % 2 == 0){
        ll q =(N/2);
        if(q % 2 == 0){
            return N;
        }else{
            return 1^N;
        }
        
    }else{
        ll q = ((N+1)/2);
        if(q%2 == 0){
            return 0;
        }else{
            return 1;
        }
    }
}

int main(){
    ll A,B;
    cin >> A >> B;
    //cout << (1^0) << endl;
    cout << (func(A-1)^func(B)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define looplt(i,x) for(i=0; i<x; ++i)
#define bsrch(v,x) binary_search(v.begin(), v.end(), x)
#define vecl vector <long long int>
#define pb(x) push_back(x)
const long long int MAX_INT =  10e+10;
typedef long long int ll;

void pvec(vector <ll> &inp)
{
    ll n;
    looplt(n, inp.size()) cout << inp[n] << " ";
    cout << endl;
}

void parr(ll inp[], ll size)
{
    ll n;
    looplt(n, size) cout << inp[n] << " ";
    cout << endl;

}

ll pw(ll a, ll b)
{
    if(b == 0)
        return (1);
    
    ll ans = 1;
    for(ll i=0; i<b; ++i) 
        ans *= a;

    return (ans);
}

bool arrsearch(ll arr[], ll size, ll val)
{
    for(ll i=0; i<size; ++i){
        if(arr[i] == val)
            return true;
    }
    return false;
}

int main()
{   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll t=1, i, k, inp, j, n, m;
    string s;
    //cin >> t;
    looplt(i, t){
        ll x, y, ans=0;
        cin >> n >> x >> y;

        ans += (n/x)*y;
        if((n%x) != 0) ans += y;
        cout << ans << "\n";
    }
}   



Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <numeric>
#include <chrono>
#include <bitset>
#include <tuple>
#include <queue>
#include <cstring>
#include <cassert>
using namespace std;

const int N = 2e5 + 10, mod = 998244353;

int fac[N], invf[N];

int fp(int a, int b) {
    int ret = 1;
    while(b) {
        if(b & 1) ret = 1ll * ret * a % mod;
        b >>= 1;
        a = 1ll * a * a % mod;
    }
    return ret;
}

int C(int n, int r) {
    return 1ll * fac[n] * invf[r] % mod * invf[n - r] % mod;
}

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    invf[0] = fac[0] = 1;
    for(int i = 1; i < N; i++) {
        fac[i] = 1ll * fac[i - 1] * i % mod;
        invf[i] = fp(fac[i], mod - 2);
    }
    int tc = 1; 
    // scanf("%d", &tc);
    for(int cn = 1; cn <= tc; cn++) {
        int n, m, k; scanf("%d%d%d", &n, &m, &k);
        int ans = 0;
        for(int i = 0; i <= k; i++) {
            int cur = 1ll * m * fp(m - 1, n - 1 - i) % mod * C(n - 1, i) % mod;
            ans = (1ll * ans + cur) % mod;
        }
        printf("%d\n", ans);
    }  
    return 0;
}

Measured memory_bytes: 5424
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;


int main (){
  ll n,k;
  ll an=0;
  ll an2=0;
  cin>>n>>k;
  vector<ll>a(n,0);
  vector<ll>b(43,0);
  for(ll i=0;i<n;i++){
    cin>>a[i];
    for(ll j=0;j<43;j++){
      if((ll)((ll)a[i]>>j)&(ll)1)b[j]++;
    }
  }
  ll c=0;
  for(ll j=42;j>=0;j--){
    if(b[j]<(n+1)/2){
      c+=((ll)1<<j);
    }
  }
  if(c<=k){
    ll d=c;
    for(ll t=0;t<43;t++){
      if((ll)(d>>t)&(ll)1)an2+=((ll)(n-b[t]))*((ll)1<<t);
      else an2+=(ll)b[t]*((ll)1<<t);
    }
    cout<<an2<<endl;
    return 0;
  }
  for(ll j=42;j>=0;j--){
    if((c&((ll)1<<j))>k){
      c-=((ll)1<<j);
    }
  }
  for(ll j=42;j>=0;j--){
    ll d=(ll)c&((ll)~((ll)1<<j));
    an2=0;
    if(d<=k){
      for(ll t=0;t<43;t++){
        if((ll)(d>>t)&(ll)1)an2+=((ll)(n-b[t]))*((ll)1<<t);
        else an2+=(ll)b[t]*((ll)1<<t);
      }
      an=max(an,an2);
    }
    else{
      c=d;
    }
  }
  cout<<an<<endl;
}


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

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

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();
    let mut a_sum: usize = 0;
    for _ in 0..m {
        let a: usize = iterator.next().unwrap().parse().unwrap();
        a_sum += a;
    }

    return if a_sum > n {
        "-1".to_string()
    } else {
        format!("{}", n - a_sum)
    };
}


Measured memory_bytes: 2212
package main

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

func main() {
	X := readint()
	ans := "No"
	if 30 <= X {
		ans = "Yes"
	}
	fmt.Println(ans)
}

const (
	iobufsize = 1 * 1024 * 1024 // 1 MB
)

var stdinsc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, iobufsize), iobufsize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func readint() int {
	stdinsc.Scan()
	v, err := strconv.Atoi(stdinsc.Text())
	if err != nil {
		panic(err)
	}
	return v
}

func readstr() string {
	stdinsc.Scan()
	return stdinsc.Text()
}

func pow(x, y int) int {
	if y < 1 {
		return 1
	}
	return x * pow(x, y-1)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 1808
//D - Caracal vs Monster

#include <iostream>

using ll = long long;

using namespace std;

ll myPow(ll _x, ll _n)
{
    ll ret = 1;
    while(0 < _n){
        if((_n % 2) == 0){
            _x *= _x;
            _n >>= 1;
        }else{
            ret *= _x;
            --_n;
        }
    }
    return ret;
}

int main()
{
    ll h;

    cin >> h;

    ll cnt = 0;
    ll ans = 0;

    while(h>0) {
        h = h/2;
        cnt++;
    }

    for (ll i=0; i<cnt; i++){
        ans += myPow(2, i);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int numbers[3],temp;

	scanf("%d %d %d", &numbers[0], &numbers[1], &numbers[2]);
	if (numbers[0]>numbers[1]) {
	    temp = numbers[0];
		numbers[0] = numbers[1];
	    numbers[1] = temp;
	}
	if (numbers[1]>numbers[2]) {
		temp = numbers[1];
		numbers[1] = numbers[2];
		numbers[2] = temp;
	}
	if (numbers[0]>numbers[1]) {
		temp = numbers[0];
		numbers[0] = numbers[1];
		numbers[1] = temp;
	}
	printf("%d %d %d\n", numbers[0], numbers[1], numbers[2]);
}

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

int main () {
  int P, Q, R;
  cin >> P >> Q >> R;
  if (P>Q) {
    int tmp=P; P=Q; Q=tmp;
  }
  if (Q>R) {
    int tmp=Q; Q=R; R=tmp;
  }
  cout << P+Q << endl;
  return 0;
}

Measured memory_bytes: 256