akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,K;
    string S,T;
    cin >> N >> K >> S;
    T=S;
    reverse(T.begin(),T.end());
    S=S+T;
    char c='z';
    rep(i,S.size()){
        chmin(c,S[i]);
    }
    ll now=0,mx=0;
    rep(i,S.size()){
        if(S[i]==c){
            now++;
        }
        else{
            now=0;
        }
        //cout << now << endl;
        chmax(mx,now);
    }
    //cout << S << mx << endl;
    K--;
    ll cnt=0,k=mx;
    while(cnt<K&&k<N){
        cnt++;
        k*=2;
    }
    chmin(k,N);
    reverse(S.begin(),S.end());
    string min;
    rep(i,N+1){
        min+="z";
    }
    rep(i,S.size()/2){
        if(S[i]==c){
            chmin(min,S.substr(i));
        }
    }
    rep(i,k){
        cout << c;
    }
    if(N-k!=0){
        cout << min.substr(mx,N-k) << endl;
    }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)
typedef vector<int> Array;
typedef vector<Array> Graph;
int dist1[100005];
int dist2[100005];
Graph G(100005);
int N;

void dfs1(int now, int dist){
    dist1[now] = dist;
    for(int i=0;i<G[now].size();i++){
        if(dist1[G[now][i]]==-1){
            dfs1(G[now][i], dist+1);
        }
    }
}

void dfs2(int now, int dist){
    dist2[now] = dist;
    for(int i=0;i<G[now].size();i++){
        if(dist2[G[now][i]]==-1){
            dfs2(G[now][i], dist+1);
        }
    }
}

int main(){
    cin >> N;
    int as[N];
    int bs[N];
    REP(i, N-1){
        int a, b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    REP(i, N){
        dist1[i] = -1;
        dist2[i] = -1;
    }
    dfs1(0, 0);
    dfs2(N-1, 0);
    int x=0;
    REP(i, N){
        if(dist1[i]<=dist2[i]) x++;
    }
    cout << (x>N-x?"Fennec":"Snuke") << endl;
    return 0;
}

Measured memory_bytes: 9600
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    long k, a, b;
    scan(k, a, b);

    if (b - a <= 2) {
        writeln(k + 1);
        return;
    }

    if (k < a - 1) {
        writeln(k + 1);
        return;
    }

    long ans = a;
    k -= a - 1;
    ans += (b - a) * (k / 2);
    if (k & 1) ans++;
    writeln(ans);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 1007, K = 21, MOD = 1000 * 1000 * 1000 + 7;

int mod(int n) {
    n %= MOD;
    if (n < 0) return n + MOD;
    else return n;
}   
int fp(int a, int p) {
    int ans = 1, c = a;
    for (int i = 0; (1ll << i) <= p; ++i) {
        if ((p >> i) & 1) ans = mod(ans * c);
        c = mod(c * c);
    }   
    return ans;
}   
int dv(int a, int b) { return mod(a * fp(b, MOD - 2)); }
void add(int &a, int b) {
    a = mod(a + b);
}

int C[N][N];
int dp[K][N];
int a[K];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    for (int i = 0; i < N; ++i) 
        C[i][0] = 1;
    for (int i = 1; i < N; ++i)
        for (int j = 1; j < N; ++j)
            C[i][j] = mod(C[i - 1][j - 1] + C[i - 1][j]);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < k; ++i)
        cin >> a[i];
    dp[0][0] = 1;
    for (int i = 0; i < k; ++i) 
        for (int j = 0; j <= n; ++j) 
            for (int t = 0; j + t <= n && t <= a[i]; ++t) 
                add(dp[i + 1][j + t], dp[i][j] * mod(C[n - j][t] * C[n - t][a[i] - t]));
    cout << dp[k][n] << '\n';
}   

Measured memory_bytes: 8320
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lb(x) x&-x
#define il inline
#define ll long long
#define llu unsigned long long
#define mem(x) memset(x,0,sizeof(x))
#define mem3(x) memset(x,0x3f,sizeof(x))
#define ccA() puts("耐心冷静查代码")
#define cc() puts("谁知盘中餐，粒粒皆辛苦")
#define fo(i,a,b) for(register int i=a;i<=b;++i)
#define fd(i,a,b) for(register int i=a;i>=b;--i)
#define fk(i,j) for(register int i=fir[j];i;i=nxt[i])
using namespace std;
inline ll read(){
    ll x=0,f=1;char c;
    for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());
    return x*f;
}
inline void write(ll a){
    if(a==0){putchar('0');return;}
    if(a<0)putchar('-'),a=-a;
    char c1[120];
    ll h=0;
    while(a)c1[++h]=a%10+'0',a/=10;
    fd(i,h,1)putchar(c1[i]);return;
}
inline void write_(ll a){write(a);putchar(' ');}
inline void writeln(ll a){write(a);putchar('\n');}
//------------------------------------------------------
int n;
int main(){
	n=read();
	writeln((n-2)*180);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static int[] n;
    public static int m;
    public static String s;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
        s=sc.next();
        if(s.equals("-")){
            sc.close();
            return;
        }
        m=sc.nextInt();
        n=new int[m];
        for(int i=0;i<m;i++){
            int len=s.length();
            n[i]=sc.nextInt();
            String a=s.substring(0,n[i]);
            String b=s.substring(n[i],len);
            s=b+a;
        }
        System.out.println(s);
    }
}
}


Measured memory_bytes: 26420
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
vector<vector<string>> S;
int N;
int main() {
	cin >> N;
	vector<string> A;
	vector<string> empty;
	A.push_back("a");
	S.push_back(A);
	for (int i = 1; i < N; i++) {
		S.push_back(empty);
		for (int j = 0; j < S[i - 1].size(); j++) {
			char maxchar = 'a';
			for (int k = 0; k < S[i - 1][j].length(); k++) {
				maxchar = max(maxchar, S[i - 1][j][k]);
			}
			maxchar++;

			for (char c = 'a'; c <= maxchar; c++) {
				S[i].push_back(S[i - 1][j] + c);
			}
		}
	}
	sort(S[N - 1].begin(), S[N - 1].end());
	for (int i = 0; i < S[N - 1].size(); i++) {
		cout << S[N - 1][i] << endl;
	}
}

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

int main()
{
    string c1, c2, rc1, rc2;
    cin >> c1;
    cin >> c2;

    rc1 = {c2.at(2), c2.at(1), c2.at(0)};
    rc2 = {c1.at(2), c1.at(1), c1.at(0)};

    // cout << rc1 << endl;
    // cout << rc2 << endl;

    if ((c1 == rc1) && (c2 == rc2))
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int ans=0;
		for(int i=1; i<n; i++){
			if(i!=n-i){
				ans++;
			}
		}
		System.out.println(ans/2);
	}
}


Measured memory_bytes: 23892
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {


        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.equals("RRR")) {
            System.out.println(3);
        } else if (s.equals("RRS") || s.equals("SRR")) {
            System.out.println(2);
        } else if(s.equals("SSS")){
            System.out.println(0);
        } else {
            System.out.println(1);
        }

    }

}

Measured memory_bytes: 35564
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    string s;
    cin >> s;
    string k = "keyence";
    int skip = 0;
    bool flag = true;
    while(s.front()==k.front()){
        s.erase(s.begin());
        k.erase(k.begin());
        if(k.empty()){
            cout << "YES\n";
            return 0;
        }
    }
    string back = "";
    for(int i=s.size()-k.size(); i<s.size(); ++i)back+=s[i];
    if(k==back)cout << "YES\n";
    else cout << "NO\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
#define ll long long

int main() {
    int n;
    string s;
    cin >> n >> s;
    ll ans = 0;
    vector<ll> a(3, 0);
    for(int i = 0; i < n; i++) {
        if(s[i] == 'R') a[0]++;
        if(s[i] == 'G') a[1]++;
        if(s[i] == 'B') a[2]++;
    }
    ans = a[0]*a[1]*a[2];
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            int k = j+j-i;
            if(k < n) {
                if(s[i] == s[j]) continue;
                if(s[j] == s[k]) continue;
                if(s[k] == s[i]) continue;
                ans--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#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 <numeric>
#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 t[1000000];

void factor(ll v) {
    for (int i = 2; i * i <= v; ++i) {
        int cnt = 0;
        while (v % i == 0) {
            cnt++;
            v /= i;
        }
        t[i] = max(t[i], cnt);
    }
    if (v != 1) {
        t[v] = max(t[v], 1);
    }
}

ll pow(ll a, ll b) {
    if (b == 0) return 1;
    if (b % 2) return a * pow(a, b - 1);
    return pow(a * a, b / 2);
}
//a^(-1)≡a^(p-2) (mod p) (but p is prime)
ll powMod(ll a, ll b, ll p) {
    if (b == 0) return 1;
    if (b % 2) return (a * powMod(a, b - 1, p)) % p;
    return powMod(a * a % p, b / 2, p);
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        factor(a[i]);
    }
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += powMod(a[i], MOD7 - 2, MOD7);
        sum %= MOD7;
    }
    for (int i = 0; i < 1000000; ++i) {
        if (t[i] > 0) {
            for (int j = 0; j < t[i]; ++j) {
                sum *= i;
                sum %= MOD7;
            }
        }
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 2944
# 子供の人数を取得
N = int(input())

# 子供の人数分のキャンディの個数を計算
Childrencnt = 1
Candysum = 0
for Childrencnt in range(1, N+1):
    Candysum = Candysum + Childrencnt

# キャンディの合計個数を出力
else:
    print(Candysum)

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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/




signed main()
{
	int n; cin >> n;
	string s; cin >> s;
	vector<int> b(26,0);

	for(const auto &c: s){
		b[c-'a']++;
	}
	int ans = 1;
	for(auto &&c: b){
		if(c != 0) ++c;
	}
	for(const auto &z: b){
		if(z != 0)
		ans = (ans*z)%MOD;//ans*=にしない
	}

	cout << ans-1;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

vector<pair<ll,int>> soinsuu_bunkai(ll N){

    vector<pair<ll,int>> res;
    ll t = N;
    for(ll i=2;i*i<=N;i++){
        if(t == 1) break;
        if(t % i == 0){
            ll prime = i;
            int cnt = 0;
            while(t % i == 0){
                t /= i;
                cnt++;
            }
            res.push_back(make_pair(prime,cnt));
        }
    }
    if(t != 1)
        res.push_back(make_pair(t,1));
    return res;
}

int main(){

    ll N;
    cin >> N;

    auto primes = soinsuu_bunkai(N);
    int res = 0;
    for(auto p : primes){
        int cnt = 1;
        int t = p.second;
        while(t >= cnt){
            t -= cnt++;
            res++;
        }
    }
    
    cout << res;
    return 0; 
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  ll n;
  cin >> n;
  ll a[300010];
  rep(i, n) cin >> a[i];
  ll ans = 0;
  ll pow2 = 1;
  //下からi番目のbit
  rep(i, 70)
  {
    ll cnt = 0;
    rep(j, n)
    {
      if (a[j] % 2 == 1)
        cnt++;
      a[j] /= 2;
    }
    ans += cnt * (n - cnt) % MOD * pow2 % MOD;
    pow2 *= 2;
    ans %= MOD, pow2 %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.trim().split_whitespace();
    let N: i64 = iter.next().unwrap().parse().unwrap();
    if N <= 999 {
        println!("ABC")
    } else {
        println!("ABD")
    }
}

Measured memory_bytes: 4352
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int Q = sc.nextInt();
    int[] T = new int[Q];
    int[] F = new int[Q];
    String[] C = new String[Q];
    for (int i = 0; i < Q; i++) {
      T[i] = sc.nextInt();
      if (T[i] == 2) {
        F[i] = sc.nextInt();
        C[i] = sc.next();
      }
    }
    sc.close();

    StringBuilder pre = new StringBuilder();
    StringBuilder suf = new StringBuilder();
    boolean rev = false;
    for (int i = 0; i < Q; i++) {
      if (T[i] == 1) {
        rev = rev ? false : true;
      } else if (T[i] == 2) {
        if (F[i] == 1) {
          if (rev) {
            suf.append(C[i]);
          } else {
            pre.append(C[i]);
          }
        } else if (F[i] == 2) {
          if (rev) {
            pre.append(C[i]);
          } else {
            suf.append(C[i]);
          }
        }
      }
    }
    pre.reverse();

    StringBuilder ans = new StringBuilder(S);
    if (rev) {
      ans.reverse();
      StringBuilder tmp = pre;
      pre = suf;
      suf = tmp;
      pre.reverse();
      suf.reverse();
    }
    ans = new StringBuilder()
        .append(pre)
        .append(ans)
        .append(suf)
        ;

    System.out.println(ans);
  }
}

Measured memory_bytes: 156800
N=int(input())
k=list(map(int,input().split()))
b = 0
for i in reversed(range(1, N)):
    if(k[i-1] > k[i]):
        k[i-1] -= 1
        if(k[i-1] > k[i]):
            b = 1


if(b == 0 or N == 1):
    print("Yes")
else:
    print("No")

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

int main() {
	int a;
	cin >> a;
	if (a == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int b, c;
		cin >> b >> c;
		cout << b + c << endl;
	}
}

Measured memory_bytes: 256
import math

n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))

def sorted_index(x, nums):
    sorted_nums = sorted(nums)
    ans = sorted_nums.index(x)
    return ans


def dict_index(num):
    ans=0
    for i in range(n-1):
        x = num[i]
        idx = sorted_index(x, num[i:])
        ans += (math.factorial(n-i-1)*idx)
    return ans

ansp = dict_index(p)
ansq=dict_index(q)
print(abs(ansp-ansq))

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << 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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

int n, m;
string fi[2100];

int main() {
    while (cin >> n >> m) {
        if (n == 0) break;
        for (int i = 0; i < n; ++i) cin >> fi[i];

        int wid[510][510];
        memset(wid, 0, sizeof(wid));
        for (int i = 0; i < n; ++i) for (int j = m-1; j >= 0; --j) {
            if (fi[i][j] != '.') continue;
            chmax(wid[i][j], wid[i][j+1] + 1);
            //cout << i << ", " << j << " : " << wid[i][j] << endl;
        }
            
        int res = 0;
        for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
            int h = 0;
            int Min = wid[i][j];
            for (int k = i; k <= n; ++k) {
                ++h;
                chmin(Min, wid[k][j]);
                chmax(res, h * Min);
            }
        }
         
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 2512
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int h = sc.nextInt();
	int w = sc.nextInt();
	String[] s = new String[h];
	for(int i = 0; i < h; i++) {
		s[i] = sc.next();
	}
	char[][] a = new char[h + 2][w + 2];
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			a[i + 1][j + 1] = s[i].charAt(j);
		}
	}
	int cout = 0;
	int[][] b = new int[h][w];
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(a[i + 1][j + 1] == '.') {
				for(int p = -1; p < 2; p++) {
					for(int q = -1; q < 2; q++) {
						if(a[i + 1 + p][j + 1 + q] == '#') {
							b[i][j]++;
						}
					}
				}
			cout = 0;
			}
		}	
	}
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(a[i + 1][j + 1] == '#') {
				System.out.print("#");
			} else {
				System.out.print(b[i][j]);
			}
		}
		System.out.println("");      
	}
}
}

Measured memory_bytes: 24276
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;


long long int N, M, K, H, W, L, R;

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

	cin >> N >> M >> K >> L;
	L %= 2;
	long long int ans = N - M;
	if (L) {
		ans *= -1;
	}
	cout << ans << endl;
	return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var s = int.Parse(Console.ReadLine());
        var hash = new HashSet<int>();

        int current = s;
        hash.Add(s);
        int m = 2;
        while (true)
        {
            int next;
            if (current % 2 == 0)
            {
                next = current / 2;
            }
            else
            {
                next = 3 * current + 1;
            }
            if (hash.Contains(next))
            {
                break;
            }
            else
            {
                hash.Add(next);
            }
            current = next;
            m++;
        }

        Console.WriteLine(m);
    }

}



Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18;
const lli MOD = 1e9+7;

bool m[N];
vi primes(1,2);
ld nk[N][N];
void sieve(){
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7


int main(){_
	lli n; cin>>n;
	string s = "";
	while(n>0){
		n--;
		s+=('a'+(n%26));
		n/=26;
	}
	reverse(all(s));
	cout<<s<<ENDL;

}


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

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

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

    int open[n] = {0}, close[n] = {0};
    for (int i = 0; i < m; i++) {
        int l, r;
        scanf("%d %d", &l, &r);
        l--;
        r--;

        open[l]++;
        close[r]++;
    }

    int cnt = 0;
    int acc = 0;
    for (int i = 0; i < n; i++) {
        acc += open[i];
        if (acc == m)
            cnt++;
        acc -= close[i];
    }

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

    return 0;
}


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

int main(){
    string s;

    cin >> s;
    
    int counter=0;
    const int NUM=3;
    for (int i=0; i<NUM; i++){
        if (s[i]=='1'){   //s[i]はchar型で""は不可"
            counter++;
        }
    }

    cout << counter <<endl;

    return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n){
        int num[2000]={},co=n,sum=0;
        for(int i=0;i<n;i++){
            cin>>num[i];
            sum+=num[i];
        }
        for(int i=1;sum>0;i++)sum-=i;
        bool NA=0;
        for(int i=0;!NA&&i<10000&&sum==0;i++){
            bool kawa=1;
            for(int j=0;j<co&&kawa;j++)if(num[j]!=j+1)kawa=0;
            if(kawa){
                NA=1;
                cout<<i<<endl;
            }
            num[co]=co+1;
            for(int j=0;j<=co;j++){
                if(num[j]==1)for(int k=j+1;k<=co&&num[j]==1;k++)if(num[k]!=1)swap(num[j],num[k]);
                num[j]--;
            }
            for(int j=co+1;j>=0;j--){
                if(num[j]!=0){
                    co=j+1;
                    break;
                }
            }
        }
        if(!NA)cout<<-1<<endl;
    }
}

Measured memory_bytes: 1168
from itertools import combinations
N = int(input())
A = [0 for _ in range(5)]
for _ in range(N):
    a = input().strip()
    if a[0]=="M":
        A[0] += 1
    elif a[0]=="A":
        A[1] += 1
    elif a[0]=="R":
        A[2] += 1
    elif a[0]=="C":
        A[3] += 1
    elif a[0]=="H":
        A[4] += 1
cnt = 0
for x in combinations(range(5),3):
    cnt += A[x[0]]*A[x[1]]*A[x[2]]
print(cnt)

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

int main(){
    int blue, red;

    //青カードの文字列を入力
    cin >> blue;
    vector<string> blue_word(blue);
    for (int i=0; i < blue; i++){
        cin >> blue_word.at(i);
    }

    //赤カードの文字列を入力
    cin >> red;
    vector<string> red_word(red);
    for (int i=0; i < red; i++){
        cin >> red_word.at(i);
    }

    int max_point = 0;
    vector<int> point(blue, 0);

    for (int i=0;i < blue; i++){
        //青カード文字列と一致で一円追加
        for (int j=0; j < blue; j++){
            if (blue_word.at(i) == blue_word.at(j)){
                point.at(i)++;
            }
        }
        //赤カード文字列と一致で一円搾取
        for (int j=0; j < red; j++){
            if (blue_word.at(i) == red_word.at(j)){
                point.at(i)--;
            }
        }

        max_point = max(max_point, point.at(i));
    }

    cout << max_point << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int a,m[201],n[201],i,s,min;
  s=0; min=10000;
  
  scanf("%d",&a);
  for(i=1;i<=a;i++){
    scanf("%d",&m[i]);
  }
  for(i=1;i<=a;i++){
	while(m[i]%2 == 0){
	  n[i]=m[i]/2;
	  s=s+1;
	  m[i]=n[i];
	}
    if( min >= s ){
	  min=s;
	}
	else{
	  min=min;
	}
	s=0;
  }
  printf("%d\n",min);
  return 0;
}

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

int main(){

int i,j,H,W;
while (1) {
	cin >>H>>W;
	if (H!=0 || W!=0) {
		for (i=0;i<H;i++) {
			for (j=0;j<W;j++) {
				cout <<"#";
			}
			cout <<endl;
		}
	cout <<endl;
	} else break;
}

}



Measured memory_bytes: 3088
#include<stdio.h>
   int main()
   {
   	    int n,h,m,s;
		   scanf("%d",&n);
		   h=n/3600;
		   m=(n-h*3600)/60;
		   s=n-h*3600-m*60;
		   printf("%d:%d:%d\n",h,m,s);
   	      
   	    
		   return 0;
   } 


Measured memory_bytes: 2128
#include<iostream>
#include <string.h>
#include<stdio.h>
#include <math.h>

using namespace std;

int main(){

	int N;
	int a;
	cin >> N;

	long long int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 3 == 0 || i % 5 == 0) {
			a = 0;
		}
		else a = i;
		ans += a;
	}

	cout << ans << endl;

return 0;
}


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

int main(){
  int64_t N; cin >> N;

  int ans = 9999999;
  int sqrtN = sqrt(N)+1;

  for(int i=sqrtN; i>0; i--){
    if(N % i == 0){
      int64_t A = i, B = N/i;
      int digA = 0, digB = 0;
      while(A>0) {A /= 10; digA++;}
      while(B>0) {B /= 10; digB++;}
      ans = min(ans, max(digA, digB));
      break;
    }
  }
  
  cout << ans << endl;
} 

Measured memory_bytes: 256
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 k = sc.nextInt();

		int max = Math.max(Math.max(a, b), c);
		int sum = a + b + c - max;

		for (int i = 0; i < k; i++) {
			max *= 2;
		}

		System.out.println(sum + max);

		sc.close();

	}

}


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

#define ll long long

using namespace std;

int main(){
    int n;
    cin>>n;
    for(int i=1; i<=9;i++){
        for(int j=1; j<=9; j++){
            if(i*j==n){
                cout<<"Yes"<<endl;
                return(0);
            }
        }
    }

cout<<"No"<<endl;

}

    
    







Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
#define NUM 100
#define INF 1000000000

int X_dim[NUM];
int Y_dim[NUM];
int M[NUM][NUM];

void init(){
    for(int i = 0; i < NUM; i++){
        for(int j = 0; j < NUM; j++){
            if(i == j){
                M[i][j] = 0;
            }else{
                M[i][j] = INF;
            }
        }
    }

}

int main(void){
    init();

    int n;
    scanf("%d", &n);

    for(int i = 0; i < n; i++){
        scanf("%d %d", &X_dim[i], &Y_dim[i]);
    }

    for(int k = 1; k <= n - 1; k++){
        for(int x = 0; x + k <= n - 1; x++){
            for(int t = x; t <= x + k - 1; t++){
                M[x][x + k] = min(M[x][x + k], M[x][t] + M[t + 1][x + k] + X_dim[x] * Y_dim[t] * Y_dim[x + k]);
                // printf("M[%d][%d]: M[%d][%d] + M[%d][%d] + %d * %d * %d\n", x, x + k, x,t,t+1,x+k,X_dim[x],Y_dim[t],Y_dim[x+k]);
            }
        }
    }

    printf("%d\n", M[0][n - 1]);
}



Measured memory_bytes: 3252
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x,n;
  cin>>x>>n;
  set<int> p;
  REP(i,n) {
    int a;
    cin>>a;
    p.insert(a);
  }
  REP(i,100) {
    if (p.count(x - i) == 0) {
      cout<<x-i<<endl;
      return 0;
    }
    if (p.count(x + i) == 0) {
      cout<<x+i<<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main(void){
	uint32_t N;
	int32_t *A;

	cin >> N;
	A = new int32_t[N];
	for(uint32_t i = 0;i < N;++i)
		cin >> A[i];

	uint32_t SignNum = 0;

	for(uint32_t i = 0;i < N;++i){
		if(A[i] < 0)
			++SignNum;		
	}

	int64_t res = 0;
	for(uint32_t i = 0;i < N;++i)
		res += abs(A[i]);

	if(SignNum & 0x01){
		int32_t Minimum = abs(A[0]), tmp;
		for(uint32_t i = 1;i < N;++i){
			tmp = abs(A[i]);
			if(tmp < Minimum)
				Minimum = tmp;
		}
		cout << setprecision(20) << res - (2 * Minimum) << endl;
	}else{
		cout << setprecision(20) << res << endl;
	}

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){
    
    int t; cin>>t;
    REP(kai,t){
        int out=0;
        int point=0;
        bool rui[3]={false,false,false};
        while(true){
            string s; cin>>s;
            if(s=="OUT"){
                out++;
                if(out==3)goto nextf;
            }else if(s=="HOMERUN"){
                point++;
                REP(j,3)if(rui[j])point++;
                REP(j,3)rui[j]=false;
            }else{
                if(rui[2])point++;
                rui[2]=rui[1];
                rui[1]=rui[0];
                rui[0]=true;
            }
        }
    nextf:;
        cout<<point<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3024
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <bit>
#include <bitset>
#include <iomanip>
#include <queue>
typedef long long int ll;
using namespace std;
int main() {
	int N, W; cin >> N >> W;
	vector<ll>weight(N), value(N);
	for (int i = 0; i < N; i++) cin >> weight[i] >> value[i];
	
	ll sum_val=0;
	for (int i = 0; i < N; i++)sum_val += value[i];
    vector<vector<ll>>DP(N+1, vector<ll>(sum_val+1,1000000000000));
	for (int i = 0; i <= N; i++)DP[i][0] = 0;
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= sum_val; j++) {
			if (j >= value[i]) {
				DP[i + 1][j] = min(DP[i][j], DP[i][j - value[i]] + weight[i]);
			}
			else {
				DP[i + 1][j] = DP[i][j];
			}
			if (DP[i + 1][j] <= W && j > ans)ans = j;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 82588
/*
    @uthor: Amit Kumar
    user --> CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll long long
#define ld double
#define endl "\n"

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}


void virus(){
         ll len;
         cin>>len;
         vector<ll> arr(len);
         for(auto &i:arr) cin>>i;
         vector<ll> dp(len);
         dp[0] = 0, dp[1] = abs(arr[1]-arr[0]);
         for(auto i=2; i<len; i++){
             dp[i] = min(dp[i-1] + abs(arr[i]-arr[i-1]),dp[i-2] + abs(arr[i] - arr[i-2]));
         }
         cout<<dp[len-1];
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
         //auto start = high_resolution_clock::now();
           virus();
         //auto stop = high_resolution_clock::now();
         //auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define ALL(v) v.begin(), v.end()

typedef long long ll;
const ll INF = 1e9;
const ll MOD = 10e9 + 7;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 * v.push_back(m) vectorへの追加
 * v.size() vectorの大きさ
 * pair<型, 型> 変数名
 * p.first, p.second
 * map<型, 型> 変数名  // 連想配列
 * priority_queue<型> 変数名  // 最大値から出てくるヒープ
*/
int main()
{
    cin.tie(0);

    string S;
    cin >> S;
    if (S.at(0) != S.at(1) && S.at(1) != S.at(2) && S.at(2) != S.at(0))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr int INF = 1001001001;
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 (a>b) { a=b; return 1; } return 0; }

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep (i, n) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(s.begin(), s.end());
    
    string pre = s[0];
    ll cnt = 1, ans = 0;
    rep (i, 1, n) {
        if (s[i] == pre) cnt++;
        else {
            ans += cnt * (cnt-1) / 2;
            cnt = 1;
            pre = s[i];
        }
    }
    ans += cnt * (cnt-1) / 2;
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 6360
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
    string t; cin >> t;
    transform(t.begin(), t.end(), t.begin(), ::toupper);
    string s;
    int c = 0;
    while (cin >> s) {
        if (s == "END_OF_TEXT") {
            break;
        }
        transform(s.begin(), s.end(), s.begin(), ::toupper);
        if (s == t) {
            c ++;
        }
    }
    cout << c << "\n";
    return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n, ma, mb;
    cin >> n >> ma >> mb;
    int a, b, c;
    vector<vector<int>> arr;
    int sA = 0, sB = 0, sC = 0;
    for(int i = 0; i < n; i++) {
        cin >> a >> b >> c;
        arr.push_back({a, b, c});
        sA += a;
        sB += b;
        sC += c;
    }
    vector<vector<int>> dp(sA+1, vector<int>(sB+1, sC+1));
    dp[0][0] = 0;
    for(int k = 0; k < n; k++) {
        a = arr[k][0];
        b = arr[k][1];
        c = arr[k][2];
        for(int i = sA; i >= a; i--) {
            for(int j = sB; j >= b; j--) {
                dp[i][j] = min(dp[i][j], dp[i-a][j-b] + c);
            }
        }
    }
    int ans = sC+1;
    for(int k = 1;; k++) {
        if (ma*k > sA || mb*k > sB)
            break;
        ans = min(ans, dp[ma*k][mb*k]);
    }
    if (ans == sC+1) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 512
#include <iostream>
#include <vector>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, k, s;

int main() {
	cin >> n >> k >> s;
	
	int i;
	vector<int> ans;
	for (i = 0; i < k; i++) ans.push_back(s);
	
	if (s == 1000000000) {
		for (i = 0; i < n - k; i++) ans.push_back(1);
	}
	else {
		for (i = 0; i < n - k; i++) ans.push_back(s + 1);
	}
	
	for (i = 0; i < ans.size(); i++) {
		cout << ans[i];
		if (i + 1 < ans.size()) cout << " ";
	}
	cout << endl;
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    // Sunny, Cloudy, Rainy 
    if(s=="Sunny") cout << "Cloudy";
    if(s=="Cloudy") cout << "Rainy";
    if(s=="Rainy") cout << "Sunny";
    return 0;
}

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

int main(){
  string S,T;
  cin >>S;
  cin >>T;
  int length = S.size();

  for(int i=0;i<length+1;i++){
    if(S == T){
      cout << "Yes" << endl;
      break;
    }
    char idx = S[0];
    S.erase(S.begin());
    S = S + idx;
  }
  if(S !=T){
    cout << "No" << endl;
  }
}



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

using namespace std;

#define ll long long
#define ii pair<int ,int>
#define iii tuple<int ,int, int>
#define vi vector<int>
#define vii vector<int, int>
#define fo(i,a,n) for(int i = (a); i < (n); i++)
#define pb push_back
#define newl cout<<"\n"
#define mp make_pair
#define mt make_tuple
#define f first
#define s second
#define N1 100000

//int visited[N1]={};
//int st[4*N1 + 10]={};
char s[20];
ll a;

int main(){
	cin>>a>>s;

	if(a<3200)cout<<"red";
	else cout<<s;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   int a, b, c;
   int tmp;
   
   scanf("%d %d", &a, &b);
   if (a < b){
      tmp = a;
      a = b;
      b = tmp;
   }
   c = a;
   while (a % b != 0){
      c = (a - a%b)/b;
      tmp = a;
      a = b;
      b =  tmp - c*b; 

   }
   printf("%d\n", b);
   return 0;
}

Measured memory_bytes: 1796
n = gets.chomp.to_i
x = gets.chomp.split(/\s/).map(&:to_f)
y = gets.chomp.split(/\s/).map(&:to_f)
xy = x.zip(y).map{ |xi, yi| (xi-yi).abs }
(1..3).each do  |p|
  puts xy.map{ |xiyi| xiyi ** p }.inject(:+) ** (1.0/p)
end
puts xy.max

Measured memory_bytes: 8856
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int INF = 1e15;

struct edge{
   int v, s;
};

int n, m;
vector<edge> G[100010];
bool visited[100010];
vector<int> d[100010][2];

void dfs(int now, int pre, bool f, int a){
    visited[now] = true;
    for(int i = 0; i < G[now].size(); i++){
        int nxt = G[now][i].v;
        int tmp = G[now][i].s - a;
        d[nxt][!f].push_back(tmp);
        if(visited[nxt]) continue;
        dfs(nxt, now, !f, tmp);
    }
}

signed main(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int u, v, s;
        cin >> u >> v >> s;
        u--; v--;
        G[u].push_back({v, s});
        G[v].push_back({u, s});
    }
    d[0][0].push_back(0);
    dfs(0, -1, 0, 0);
    int MIN = 1, MAX = INF;
    for(int i = 0; i < n; i++){
        int sa = INF, sb = INF;
        if(d[i][0].size() != 0) sa = d[i][0][0];
        if(d[i][1].size() != 0) sb = d[i][1][0];
        for(int j = 0; j < d[i][0].size(); j++){
            if(d[i][0][j] != sa) MAX = 0;
        }
        for(int j = 0; j < d[i][1].size(); j++){
            if(d[i][1][j] != sb) MAX = 0;
        }
        if(sa != INF && sb != INF){
            int t = (sb - sa) / 2;
            if((sb - sa) % 2) MAX = 0;
            else{
                if(MIN <= t && t <= MAX){
                    MIN = t; MAX = t;
                }else{
                    MAX = 0;
                }
            }
        }else if(sa != INF){
            MIN = max(MIN, -sa + 1);
        }else if(sb != INF){
            MAX = min(MAX, sb - 1);
        }
    }
    cout << max(0LL, MAX - MIN + 1) << endl;
}

Measured memory_bytes: 24832
var m,x,y,n:longint;
    i:longint;
    a:Array[0..100500]of longint;
procedure qs(l,r:longint);
var i,j,m,t:longint;
begin
  i:=l;
  j:=r;
  m:=a[(l+r)>>1];
  repeat
    while a[i]<m do inc(i);
    while a[j]>m do dec(j);
    if i<=j then
    begin
      t:=a[i];a[i]:=a[j];a[j]:=t;
      inc(i);
      dec(j);
    end;
  until i>j;
  if l<j then qs(l,j);
  if i<r then qs(i,r);
end;
function find1(x:longint):longint;
var l,r,m:longint;
begin
  l:=1;
  r:=n-1;
  while l<=r do
  begin
    m:=(l+r)>>1;
    if a[m]<x then l:=m+1 else r:=m-1;
  end;
  exit(l);
end;
function find2(x:longint):longint;
var l,r,m:longint;
begin
  l:=1;
  r:=n-1; 
  while l<=r do
  begin
    m:=(l+r)>>1;
    if a[m]>x then r:=m-1 else l:=m+1;
  end;
  exit(r);
end;
begin
  read(n);
  for i:=1 to n do
  read(a[i]);
  qs(1,n);
  m:=(a[n]+1) div 2;
  x:=find1(m);
  y:=find2(m);
  if a[x]-m<m-a[y] then writeln(a[n],' ',a[x]) else writeln(a[n],' ',a[y]);
end.


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

template <class T>
T gcd(T n, T m) {
    if (n < m) swap(n, m);
    while (m != 0) {
        T r = n % m;
        n = m;
        m = r;
    }
    return n;
}

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}

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

    int n;
    cin >> n;

    int m = 0;
    map<array<ll, 2>, array<int, 2>> mp;

    for (int i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;

        if (a == 0 && b == 0) {
            m++;

        } else {
            ll c = gcd(abs(a), abs(b));
            if (b < 0 || (b == 0 && a < 0)) c *= -1;
            a /= c;
            b /= c;

            int t = 0;
            if (a <= 0) {
                ll x = a;
                a = b;
                b = -x;
                t = 1;
            }
            mp[{ a, b }][t]++;
        }
    }

    ll r = 1;
    for (const auto& [v, k] : mp) {
        r *= powmod(2, k[0]) + powmod(2, k[1]) - 1;
        r %= P;
    }

    r += m;
    r--;
    r %= P;
    if (r < 0) r += P;

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 16116