akhauriyash/Code-Regression huggingface dataset:
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v(n);
  ll a=0;
  bool flag=false;
  rep(i,n){
    cin>>v[i];
    if(v[i]==0) flag=true;
    if(v[i]<0) a++;
    v[i]=abs(v[i]);
  }
  if(flag){
    cout<<Svec(v)<<endl;
    return 0;
  }
  if(a%2==0){
    cout<<Svec(v)<<endl;
  }else{
    sort(ALL(v));
    cout<<Svec(v)-2*v[0]<<endl;
  }
}



Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll INF = (ll)1e17;

int N, W;
int v[101], w[101];
int dp[101][10001]; //dp[i][j]:商品1~iの中から選び、ナップサックの容量がjの時に入れられる商品の価値の合計の最大値

int main(void) {
	cin >> N >> W;
	for (int i = 0; i < N; i++) cin >> v[i] >> w[i];
	
	for (int i = 0; i < 101; i++) {
		for (int j = 0; j < 10001; j++) {
			dp[i][j] = 0;
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= W; j++) {                                       //容量ははWまで
			if (j - w[i] >= 0) {                                             //商品iが入れられるとき
				dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);    //商品iを入れない場合と入れる場合の価値の大きい方
			}
			else {                       //商品iは入れられないとき
				dp[i + 1][j] = dp[i][j]; //価値はそのまま
			}
		}
	}

	cout << dp[N][W] << endl;
	return 0;
}


Measured memory_bytes: 7072
#!/usr/bin/env python3
import sys


def solve(N: int, p: "List[float]"):
    dp = [[0] * (N+1) for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(1, N+1):
        for j in range(i+1):
            if j == 0:
                dp[i][j] = dp[i-1][j]*(1-p[i-1])
            else:
                dp[i][j] = dp[i-1][j]*(1-p[i-1]) + dp[i-1][j-1]*p[i-1]

    res = 0
    for j in range(N//2+1, N+1):
        res += dp[N][j]
    print(res)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [float(next(tokens)) for _ in range(N)]  # type: "List[float]"
    solve(N, p)


if __name__ == '__main__':
    main()


Measured memory_bytes: 273288
#include<bits/stdc++.h>
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<pii>
#define pb push_back
using namespace std;
const int N=6e5+5;
vi v[N];
int n,m,id;
map<pair<int,int>,int>mp;
void add_edge(int a,int b,int c,int d)
{
	v[a].pb(make_pair(b,c));
	v[b].pb(make_pair(a,d));
}
int getid(int a,int pos)
{
	if(mp[make_pair(a,pos)])return mp[make_pair(a,pos)];
	int res=id++;
	add_edge(a,res,1,0);
	return (mp[make_pair(a,pos)]=res);
}
priority_queue<pii,vi,greater<pii> >pq;
bool visit[N];
int main()
{
	cin>>n>>m;
	id = n;
	for(int i=0;i<m;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		a--,b--;
		int x=getid(a,c);
		int y=getid(b,c);
		add_edge(x,y,0,0);
	}
/*	for(int i=0;i<id;++i)
	{
		cout<<"Vertex "<<i<<" connact:  ";
		for(int j=0;j<v[i].size();j++)cout<<v[i][j].F<<' '<<v[i][j].S<<'\n';
		cout<<endl;
	}*/
	pq.push(make_pair(0,0));
	while(!pq.empty())
	{
		int move=pq.top().F;
		int now=pq.top().S;
		pq.pop();
		if(visit[now])continue;
		visit[now]=true;
		if(now==n-1)
		{
			cout<<move<<endl;
			return 0;
		}
		for(int i=0;i<v[now].size();i++)
		{
			int to=v[now][i].F;
			pq.push(make_pair(move+v[now][i].S,to));
		}
	}
	puts("-1");
	return 0;
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename L, typename R>
ostream& operator<<(ostream& out, const pair<L, R>& p) {
    out << "(" << p.first << ", " << p.second << ")";
    return out;
}

template <typename L, typename R>
istream& operator>>(istream& in, pair<L, R>& p) {
    in >> p.first >> p.second;
    return in;
}

const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;

#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = ll(b) - 1; i >= (a); i--)
#define TR(X)                                                  \
    ({                                                         \
        if (0) cerr << "TR: " << (#X) << " = " << (X) << endl; \
    })
#define LL(name) \
    ll name;     \
    cin >> name;
#define VL(name, num) \
    vl name(num);     \
    FOR(INPUT_VL_I, 0, num) { cin >> name[INPUT_VL_I]; }

static ll f(ll cnt) {
    ll res = 0;

    for (ll i = 1; i <= cnt; i++) {
        res ++;
        cnt -= i;
    }
    TR(cnt);
    TR(res);

    return res;
}
int main() { cin.sync_with_stdio(0);
    ll N; cin >> N;

    const ll oldN = N;

    ll ans = 0;
    for (ll i = 2; i * i <= oldN; i++) {
        ll cnt = 0;
        while (N % i == 0) {
            cnt ++;
            N /= i;
        }
        if (cnt) {
            ans += f(cnt);
        }
    }

    if (N != 1) ans ++;
    cout << ans << endl;


}  // cin.tie(0) bei schnellem Wechseln


Measured memory_bytes: 3652
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main()
{
	int a, p, ans;
	cin >> a >> p;
	ans = (a * 3 + p) / 2;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int func(int x) {
  return x * x;
}

int main(void) {
  int input, i, area, cnt;

  while (scanf("%d", &input) != EOF) {
    area = 0;

    for (i = 0; i < 600; i += input)
      area += func(i) * input;

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


  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int main(){

string s,t;
long long int cnt;
cin>>s>>t;

for(int i=0;i<s.size();i++){
  if(s[i]==t[i]){
    cnt++;
  }
}

cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int selectionSort(int a[],int n){

	int i,j,minj,temp;
	int sw=0;

	for(i=0;i<n-1;i++){
		minj=i;
		for(j=i;j<n;j++){
			if(a[j]<a[minj])
				minj=j;
		}
		temp=a[i];
		a[i]=a[minj];
		a[minj]=temp;
		if(i != minj)
			sw++;
	}
	return sw;
}

int main(){

	int a[100],n,i,sw;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);

	sw = selectionSort(a,n);

	for(i=0;i<n;i++){
		if(0<i)
			printf(" ");
		printf("%d",a[i]);
	}
	printf("\n%d\n",sw);
	
	return 0;
}

Measured memory_bytes: 604
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
using namespace std;
struct node{
	int g,t;
}a[100005];
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&a[i].g,&a[i].t);
	}
	int sumstart=a[0].g;
	int sumover=a[0].t;
	for(int i=1;i<m;i++)
	{
		sumstart=max(a[i].g,sumstart);
		sumover=min(a[i].t,sumover);
	}
	int answer=sumover-sumstart+1;
	if(answer<0)
		answer=0;
	printf("%d\n",answer);
	return 0;
}

Measured memory_bytes: 3968
#include <stdio.h>
#include <string.h>
char s[10010];
int a[26], i, l;
main()
{
    while(scanf("%s", s)!=EOF)
    {
        l=strlen(s);
        for(i=0; i<l; i++)
        {
            if(s[i]==' ') continue;
            if(s[i]>='A' && s[i]<='Z') a[s[i]-'A']++;
            else if(s[i]>='a' && s[i]<='z') a[s[i]-'a']++;
        }

    }

    for(i=0; i<26; i++)
    {
        printf("%c : %d\n", 'a'+i, a[i]);
    }

}



Measured memory_bytes: 2680
import numpy as np

def main():
    A, B, H, M = map(float, input().split())
    # 偏角をどう計算するか,0を基準にどれくらい動いてるか
    omega_short = 6*M # 短針を動かす角度(not radian)
    omega_long = 0.5*M+30*H
    diff_rad = np.abs(omega_long - omega_short)
    cos_theta = np.cos(np.deg2rad(diff_rad))
    res = (A**2 + B**2 - 2*A*B*cos_theta)**(1/2)# 余弦定理
    print(res)
if __name__ == "__main__":
    main()

Measured memory_bytes: 27236
def main():
    N = int(input())
    A = [i-1 for i in map(int, input().split())]
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    ans = 0
    for idx, a in enumerate(A):
        ans += B[a]
        if idx != 0 and A[idx-1] + 1 == A[idx]:
            ans += C[A[idx-1]]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61892
#!/usr/bin/env python3
from itertools import accumulate
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))
li = [0] * 21
for x in P:
    li[x] += 1
li = list(accumulate(li))
print(min(li[A], li[B] - li[A], li[20] - li[B]))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
/*
	Karya anak bangsa yang paling agung
	Author : Yohandi or... bukan..
*/

#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define endl "\n"

#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())

#define rep(a,x,y) for(int a=(int)x;a<=(int)y;++a)
#define repd(a,x,y,d) for(int a=(int)x;a<=(int)y;a+=d)
#define res(a,x,y) for(int a=(int)x;a>=(int)y;--a)
#define resd(a,x,y,d) for(int a=(int)x;a>=(int)y;a-=d)

// Ordered Set, Ordered Multiset
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define o_multiset tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
// .order_of_key(x) -> Number of elements less than x
// * .find_by_order(k) -> Kth smallest element (0-based)
// .erase(x) -> Remove all elements equal to x

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

using namespace std;
using lint=long long;

mt19937 rng(time(NULL));

lint Power(lint A,lint B,lint C){
	if(!B) return 1LL;
	lint tmp=Power(A,B>>1,C);
	return tmp*tmp%C*(B&1?A:1)%C;
}

int T;

int main(){
//	ios_base::sync_with_stdio(0);
//	cin.tie(0); cout.tie(0);
	T=1;
//	cin>>T;
	rep(t,1,T){
        int X,N;
        cin>>X>>N;
        map<int,bool> Tag;
        for(int i=1;i<=N;++i){
            int Y;
            cin>>Y;
            Tag[Y]=1;
        }
        int Le=X;
        int Ri=X;
        if(!Tag[X]){
            cout<<X<<endl;
            return 0;
        }
        while(true){
            Le--;
            if(!Tag[Le]){
                cout<<Le<<endl;
                return 0;
            }
            Ri++;
            if(!Tag[Ri]){
                cout<<Ri<<endl;
                return 0;
            }
        }
	}
	return 0;
}




Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
typedef unsigned long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;

ll x;
int main(){
	// debug;
	ios;

	cin>>x;
	ll sum = 100;
	ll cnt = 0;
	while(sum<x){
		sum += sum/100;
		cnt++;
	}
	cout<<cnt<<'\n';
	

	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n, h[100100];
ll dp[100100];

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

    for(int i = 0; i < 100100; i++) dp[i] = inf;

    dp[0] = 0;
    for(int i = 0; i < n; i++){
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a;
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

int main() {
	string a, b;
	cin >> a >> b;
	string tmp1,tmp2;
	rep(i, stoi(a)) {
		tmp1 += b;
	}
	rep(i, stoi(b)) {
		tmp2 += a;
	}
	if (tmp1 < tmp2) {
		cout << tmp1;
	}
	else {
		cout << tmp2;
	}
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
fn main() {
    input! {
        n: i64,
        aa: [i64; n as usize],
    }

    let mut memo = HashMap::new();
    let mut ans = 0;
    for (id, tall) in aa.into_iter().enumerate() {
        let id_add_tall = id as i64 + tall;
        let id_sub_tall = id as i64 - tall;
        ans += *memo.get(&id_sub_tall).unwrap_or(&0);
        *memo.entry(id_add_tall).or_insert(0) += 1i64;
    }

    println!("{}", ans);

}


Measured memory_bytes: 11772
#include <stdio.h>
#include <math.h>
int a[101],m,i;
int main(void){
	for(;~scanf("%d",&i);m=fmax(m,++a[i]));
	for(i=0;++i<101;m-a[i]||printf("%d\n",i));
	return 0;
}

Measured memory_bytes: 0
points = 20.times.map {gets.chomp.to_i}
point_w = points[0..9].sort_by {|v| -v}[0..2].inject(:+)
point_k = points[10..19].sort_by {|v| -v}[0..2].inject(:+)
puts "#{point_w} #{point_k}"

Measured memory_bytes: 8468
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
while(true){
   var n=Arr.shift()-0;
   if(n==0)break;
   var arr=(Arr.shift()).split(" ").map(Number);
   var x=arr[0];
   var ans=[[x]];
   for(var i=1;i<n;i++){
      if(x+1==arr[i])(ans[ans.length-1]).push(arr[i]);
      else ans.push([arr[i]]);
      x=arr[i];
   }
   ans.forEach(function(v,i){
      if(v.length!==1)ans[i]=v[0]+"-"+v[v.length-1];
      else ans[i]=v[0];
   });
   console.log(ans.join(" "));
}

Measured memory_bytes: 9504
H, W = map(int,input().split())
s = list(list(input())for i in range(H))
cost = [[10**9]*W for _ in range(H)]
cost[0][0] = 0
if s[0][0] == "#":
    cost[0][0] += 1
for i in range(H-1):
    for j in range(W-1):
        if(s[i][j] == "." and s[i][j+1] == "#"):
            cost[i][j+1] = min(cost[i][j+1],cost[i][j]+1)
        else:
            cost[i][j+1] = min(cost[i][j+1],cost[i][j])
        if(s[i][j] == "." and s[i+1][j] == "#"):
            cost[i+1][j] = min(cost[i+1][j],cost[i][j]+1)
        else:
            cost[i+1][j] = min(cost[i+1][j],cost[i][j])
    if(s[i][-1] == "." and s[i+1][-1] == "#"):
        cost[i+1][-1] = min(cost[i+1][-1],cost[i][-1]+1)
    else:
        cost[i+1][-1] = min(cost[i+1][-1],cost[i][-1])
for j in range(W-1):
    if(s[H-1][j] == "." and s[H-1][j+1] == "#"):
        cost[H-1][j+1] = min(cost[H-1][j+1],cost[H-1][j]+1)
    else:
        cost[H-1][j+1] = min(cost[H-1][j+1],cost[H-1][j])

print(cost[-1][-1])

Measured memory_bytes: 3444
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

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

    vector<string> words(n);
    for (int i = 0; i < n; ++i)
        cin >> words[i];

    bool success = true;
    map<string, int> m;
    m.insert(make_pair(words[0], 1));
    char last_char = words[0][words[0].length() - 1];
    for (int i = 1; i < n; ++i) {
        if (m.find(words[i]) != m.end() || words[i][0] != last_char) {
            success = false;
            break;
        }
        m.insert(make_pair(words[i], 1));
        last_char = words[i][words[i].length() - 1];
    }

    if (success)
        cout << "Yes\n";
    else
        cout << "No\n";
}


Measured memory_bytes: 256
def solve():
  N = int(input())
  ans = [0]
  if N%2==0:
    for i in range(1,N+1):
      for j in range(i+1,N+1):
        if i+j!=N+1:
          ans[0] += 1
          ans.append([i,j])
  else:
    for i in range(1,N):
      for j in range(i+1,N):
        if i+j!=N:
          ans[0] += 1
          ans.append([i,j])
    for i in range(1,N):
      ans[0] += 1
      ans.append([N,i])
  return ans
ans = solve()
print(ans[0])
for a in ans[1:]:
  print(*a)

Measured memory_bytes: 74456
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    string a, b, c;
    cin >> a >> b >> c;
    string word = {'A', b[0], 'C'};
    cout << word << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<algorithm>
using namespace std;
int Min=(1<<30);
int n, w[105], S1=0, S2=0;
int main()
{
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		cin>>w[i];
		S2+=w[i];
	}	
	for(int i=1; i<=n; i++)
	{
		S1+=w[i];
		if(abs(S2-2*S1)<Min)
			Min=abs(S2-2*S1);
	}
	cout<<Min<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

int p[112];
int n;
int x;

int main() {
    cin >> x >> n;
    int f = 0;
    rep(i,n){
        cin >> p[i];
        if(x == p[i]) f = 1;
    }

    if (f){
        int i = 1;
        int f1 = 0;
        int f2 = 0;

        while(1){
            f1 = 0;
            f2 = 0;
            rep (j,n){
                if (p[j] == x-i) f1 = 1;
                if (p[j] == x+i) f2 = 1;
            }

            if (f1 == 0){
                cout << x-i << endl;
                return 0;
            }
            if (f2 == 0){
                cout << x+i << endl;
                return 0;
            }
            ++i;
        }
    }
    else cout << x << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll n,k,c=0;cin>>n>>k;
	while(n) c++,n/=k;cout<<c<<endl;

}


Measured memory_bytes: 256
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

//#include "math/modulo.h"

template<class T, T M>
struct modulo {
	T n;
	modulo(T n): n(n<0? n%M+M: n%M)   { }
	operator T() const                { return n;             }
	modulo operator-() const          { return modulo(-n);    }
	modulo operator+(const modulo &o) const { return modulo(n+o.n); }
	modulo operator-(const modulo &o) const { return modulo(n-o.n); }
	modulo operator*(const modulo &o) const { return modulo(n*o.n); }
	bool  operator< (const modulo &o) const { return n< o.n; }
	bool  operator<=(const modulo &o) const { return n<=o.n; }
	bool  operator> (const modulo &o) const { return n> o.n; }
	bool  operator>=(const modulo &o) const { return n>=o.n; }
	bool  operator==(const modulo &o) const { return n==o.n; }
	bool  operator!=(const modulo &o) const { return n!=o.n; }

	modulo pow(T n) const {
		modulo y = 1, x = *this;
		while (n) {
			if (n%2) y = y * x;
			n /= 2;
			x = x * x;
		}
		/*
		if (n==0) return 1;
		modulo y = pow(n/2);
		y = y*y;
		if (n%2) y = y * (*this);
		*/
		return y;
	}
	modulo inv() const {
		return pow(M-2);
	}
	modulo operator/(const modulo &o) const {
		return (*this) * o.inv();
	}

	T gcd_ext(T a, T b, T *x, T *y) {
		if (a == 0) {
			*x = 0;
			*y = 1;
			return b;
		}
		T x1, y1;
		T gcd = gcd_ext(b%a, a, &x1, &y1);
		*x = y1 - (b/a) * x1;
		*y = x1;
		return gcd;
	}
	modulo div(const modulo &o) const {
		T x, y;
		T g = gcd_ext(o.n, M, &x, &y);
		if (g != 1) return 0;
		else return modulo(n * (x % M));
	}

	friend ostream &operator<<(ostream &os, const modulo &x) {
		return os << x.n;
	}
};

typedef modulo<long,998244353> T;
//#include "math/comb.h"

void comb_inc_k(T &r, int n, int &k) {
        //C(n,k+1) = C(n,k) * (n-k) / (k+1)
	r = r * T(n-k) / T(k+1);
	k++;
}

void comb_dec_k(T &r, int n, int &k) {
        //C(n,k-1) = C(n,k) * k / (n-k+1)
	r = r * T(k) / T(n-k+1);
	k--;
}

void comb_inc_n(T &r, int &n, int k) {
        //C(n+1,k) = C(n,k) * (n+1) / (n+1-k)
	r = r * T(n+1) / T(n+1-k);
	n++;
}

void comb_dec_n(T &r, int &n, int k) {
        //C(n-1,k) = C(n,k) * (n-k) / n
	r = r * T(n-k) / T(n);
	n--;
}

T comb(int n, int k) {
    if (k*2 > n) k = n-k;
    if (n==0) return 0;
    T r = 1; //C(n,0)
    int i = 0;
    while (i<k) comb_inc_k(r, n, i);
    return r;
}


#define MAXN 100000

int n;


int input() {
	if (scanf("%d", &n) < 0) return 0;
	return 1;
}

void init() {
}

int solve() {
	T r = T(3).pow(n);
	int k = n/2;
	T e = comb(n, k);
	while (k+1<=n) {
		comb_inc_k(e, n, k);
		r = r - e*T(2).pow(n-k)*T(2);
	}
	return r;
}

void output(int ans) {
	printf("%d\n", ans);
}

void cleanup() {
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 128
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
v_even = []
v_odd = []

for i in range(n):
    if i % 2 == 0:
        v_even.append(v[i])
    else:
        v_odd.append(v[i])

even = Counter(v_even).most_common(2)+[(0,0)]
odd = Counter(v_odd).most_common(2)+[(0,0)]

if even[0][0] != odd[0][0]:
    ans = n - even[0][1] - odd[0][1]
else:
    temp1 = even[0][1] + odd[1][1]
    temp2 = even[1][1] + odd[0][1]
    temp = max(temp1, temp2)
    ans = n - temp

print(ans)

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

vector<int> sieve(int n) {
	vector<int> res{2};
	vector<bool> is_prime(n, true);

	for(int i = 3; i < n; i += 2) {
		if(is_prime[i]) {
			res.emplace_back(i);

			for(int j = i * i; j < n; j += i) {
				is_prime[j] = false;
			}
		}
	}

	return res;
}

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

	constexpr int MAX = 10000;
	const auto primes = sieve(MAX);

	for(int x; cin >> x && x;) {
		int ans = 0;

		for(unsigned i = 0; i < primes.size(); ++i) {
			if(primes[i] > x) break;

			int sum = 0;
			for(unsigned j = i; j < primes.size(); ++j) {
				sum += primes[j];
				if(sum >= x) break;
			}

			if(sum == x) ++ans;
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1240
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int A = s.nextInt();
		
		System.out.println((N%500) <= A ? "Yes" : "No");
		
	}

}

Measured memory_bytes: 20948
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

string S;
char c;
int cnt = 0;

int main()
{
    cin >> S;
    c = S[0];
    for (char s : S) {
        if (c != s) {
            cnt++;
            c = s;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long n = scan.nextLong();
        int rn = (int) Math.sqrt(n);
        long out = Long.MAX_VALUE;
        for(int i = 1; i <= rn; i++){
            if(n % i == 0){
                out = Math.min(out, i + n / i - 2);
            }
        }
        System.out.println(out);
    }
}

Measured memory_bytes: 23252
N = int(input())
a = list(map(int, input().split()))

ct = 0

for i in range(len(a)):
    if a[i] % 2 == 0:
        while True:
            a[i] = a[i] // 2
            ct += 1
            if a[i] % 2 != 0:
                break
print(ct)

Measured memory_bytes: 4212
n = int(input())
a = list(map(int, input().split()))
even = []
odd = []
for i in range(n):
    if i % 2:
        even.append(a[i])
    else:
        odd.append(a[i])
if n % 2 == 0:
    print(*even[::-1], end=" ")
    print(*odd)
else:
    print(*odd[::-1], end=" ")
    print(*even)


Measured memory_bytes: 26180
N, K = map(int, input().split())
points = [tuple(map(int, input().split())) for i in range(N)]

ptsX = sorted(points, key=lambda t: t[0])
ptsY = sorted(points, key=lambda t: t[1])

ans = float('inf')
for iLeft, ptLeft in enumerate(ptsX):
    setX = set(ptsX[iLeft:])

    for ptRight in ptsX[iLeft + 1:][::-1]:
        if len(setX) < K: break
        lenX = ptRight[0] - ptLeft[0]

        for iBottom, ptBottom in enumerate(ptsY):
            setY = set(ptsY[iBottom:])

            for ptTop in ptsY[iBottom + 1:][::-1]:
                if len(setY) < K: break

                num = len(setX & setY)
                if num < K: break

                if num == K:
                    lenY = ptTop[1] - ptBottom[1]
                    area = lenX * lenY
                    ans = min(ans, area)

                setY.remove(ptTop)

        setX.remove(ptRight)

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	if(a*b%2==0)cout << "Even" << endl;
	else cout << "Odd" << endl;
	return 0;
}


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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        int m , d;
        cin >> m >> d;
        LL ans = 0;
        for( int i = 1; i <= m; i++ ) {
                for( int j = 1; j <= d; j++ ) {
                        if( j < 10 ) continue;
                        int x = j/10 , y = j%10;
                        if( x * y == i && x >= 2 && y >= 2 ) ans++;
                }
        }
        cout << ans << endl;
        return 0;
}










Measured memory_bytes: 256
n=int(input())
L=[]
cnt=0
while(n!=0):
    cnt+=1
    a=n%(2**cnt)
    b=(1 if a>0 else 0)
    L.append(b)
    n=n-(((-2)**(cnt-1))*b)
L=list(map(str,L))[::-1]
print("".join(L) if len(L)>0 else 0)

Measured memory_bytes: 3064
#include <iostream>
 
int main(){
 
    int a[3];
    int i,j;
    std::cin >> j;
 
    for(i=0;i<j;i++){
        std::cin >> a[0] >> a[1] >> a[2];
        if(a[0]>a[1]){
	int sum=a[0];
	a[0]=a[1];
	a[1]=sum;
        }
        if(a[1]>a[2]){
	int sum1=a[1];
	a[1]=a[2];
	a[2]=sum1;
        }
        if(a[0]>a[1]){
	int sum2=a[0];
	a[0]=a[1];
	a[1]=sum2;
        }
        if(a[2]*a[2]==a[0]*a[0]+a[1]*a[1])
             std::cout << "YES" << std::endl;
        else
             std::cout << "NO" << std::endl;
        }
        return 0;
}

Measured memory_bytes: 1148
x = int(input())

a = [100, 101, 102, 103, 104, 105]
m = [1000000 for _ in range(6)]
dp = [-1 for _ in range(x+1)]

dp[0] = 0
for i in range(6):
    for j in range(x+1):
        if dp[j] >= 0:
            dp[j] = m[i]
        elif j < a[i] or dp[j-a[i]] <= 0:
            dp[j] = -1
        else:
            dp[j] = dp[j-a[i]]-1

if dp[x] >= 0:
    print(1)
else:
    print(0)


Measured memory_bytes: 44784
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String c = sc.next();
    
    if("abc".equals(c) || "acb".equals(c) || "bac".equals(c) || "bca".equals(c) || "cab".equals(c) || "cba".equals(c)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35480
def calcScore(L):
    j,score=0,0
    for i in range(10):
        if L[j]==10:
            score+=sum(L[j:j+3])
            j+=1
        elif L[j]+L[j+1]==10:
            score+=10+L[j+2]
            j+=2
        else:
            score+=L[j]+L[j+1]
            j+=2
    return score

while True:
    m=input()
    if m==0:break
    L=[map(int,raw_input().split()) for i in range(m)]
    res=[(-calcScore(i[1:]),i[0])for i in L]
    res.sort()
    for i,j in res:
        print j,-i

Measured memory_bytes: 4272
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;
    int p=0,g=0,w=0,d=0,l=0;
    for (auto ss:s) {
        if (ss=='p') ++p;
        else ++g;
    }
    int myp = (p+g)/2;
    int myg = (p+g)-myp;
    int myp_forg = min(myp,g);
    w += myp_forg;
    int myp_forp = min(myp - myp_forg,p);
    d += myp_forp;
    int res_p = p - myp_forp;
    int res_g = g - myp_forg;
    l += res_p;
    d += res_g;
    cout << w-l << endl;
    return 0;
}

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

long long dp[105][100005];

const long long inf=-1e9+5;


long long go(int wt[],int v[],int i,int n,int w)
{
      if(w<0) return inf;
    if(w==0||i>=n) return 0;

    if(dp[i][w]) return dp[i][w];

    dp[i][w]=max(v[i]+go(wt,v,i+1,n,w-wt[i]),go(wt,v,i+1,n,w));
    return dp[i][w];
}


int main()
{
    int n,w,i;
    cin>>n>>w;
    int wt[n],v[n];
    memset(dp,0,sizeof(dp));
    for(i=0;i<n;i++) cin>>wt[i]>>v[i];


    long long sum=go(wt,v,0,n,w);
    cout<<sum<<endl;

}


Measured memory_bytes: 82304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

ll dp[101010][13];

int main() {
    string s;
    cin>>s;
    int n=s.size();

    dp[0][0]=1;
    rep(dgt,n){
        rep(mo,13){
            if(s[dgt]=='?'){
                rep(nxt,10){
                    dp[dgt+1][(mo*10+nxt)%13]=(dp[dgt+1][(mo*10+nxt)%13]+dp[dgt][mo])%MOD;
                }
            }
            else{
                dp[dgt+1][(mo*10+s[dgt]-'0')%13]=(dp[dgt+1][(mo*10+s[dgt]-'0')%13]+dp[dgt][mo])%MOD;
            }
        }
    }


    cout<<dp[n][5]<<endl;
}

Measured memory_bytes: 13896
import java.util.*;

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 = b-a;
    int height = 0;

    for (int i=0; i < c; i++) {
      height += i;
    }

    System.out.println(height - a);
  }
}


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

using namespace std;

const int mod = 998244353, N = 3030;

long long dp[N][N][2];

void add(long long & var, long long val) {
  var += val;
  if (var >= mod)
    var -= mod;
}

int main() {
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  dp[a][b][0] = 1;
  for (int i = a; i <= c; ++i) {
    for (int j = b; j <= d; ++j) {
      add(dp[i+1][j][0], dp[i][j][0] * j % mod);
      add(dp[i][j+1][1], dp[i][j][0] * i % mod);
      add(dp[i+1][j][0], dp[i][j][1]);
      add(dp[i][j+1][1], dp[i][j][1] * i % mod);
    }
  }
  long long ans = (dp[c][d][0] + dp[c][d][1]) % mod;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 145640
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
 
int main(){

    int n, len;
    string s;
    cin >> n >> s;
    len = s.length();
    string letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    for (int i = 0; i < len; i++)
    {
        for (int j = 0; j < 26; j++)
        {
            if (s[i] == letter[j]){
                if(j + n < 26)
                {
                    s[i] = letter[j+n];
                }  
                if(j + n > 25)
                {
                    s[i] = letter[j+n - 25  - 1];
                }   
                break;
            }
        }
    }

    

    

    for (int i = 0; i < len; i++)
    {
        cout << s[i];
    }

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
const int N=2003,INF=0x3f3f3f3f,D=1<<11;
int n,m,q,a[N],p[N],ans=INF;
#define M (L+R>>1)
struct segment_tree{
	int mn[1<<12],mx[1<<12],s[1<<12];
	segment_tree(){memset(mn,63,sizeof mn);}
	int Min(int l,int r){
		int res=n+1;
		if(l>r)return res;
		for(l=l+D-1,r=r+D+1;l^r^1;l>>=1,r>>=1){
		  if(~l&1)res=std::min(res,mn[l^1]);
		  if( r&1)res=std::min(res,mn[r^1]);
		}return res;
	}
	int Max(int l,int r){
		int res=0;
		if(l>r)return res;
		for(l=l+D-1,r=r+D+1;l^r^1;l>>=1,r>>=1){
		  if(~l&1)res=std::max(res,mx[l^1]);
		  if( r&1)res=std::max(res,mx[r^1]);
		}return res;
	}
	int Count(int l,int r){
		int res=0;
		if(l>r)return res;
		for(l=l+D-1,r=r+D+1;l^r^1;l>>=1,r>>=1){
		  if(~l&1)res+=s[l^1];
		  if( r&1)res+=s[r^1];
		}return res;
	}
	void Update(int k,int a){
		for(k+=D,mn[k]=mx[k]=a,k>>=1;k;k>>=1)
		  mn[k]=std::min(mn[k<<1],mn[k<<1|1]),
		  mx[k]=std::max(mx[k<<1],mx[k<<1|1]);
	}
	void Erase(int k){
		for(k+=D,s[k]=1,k>>=1;k;k>>=1)
		  s[k]=s[k<<1]+s[k<<1|1];
	}
}f,g;
bool Cmp(const int&i,const int&j){return a[i]<a[j];}
int main(){
	int mn,mx,l,r;
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++)scanf("%d",a+i),p[i]=i;
	std::sort(p+1,p+1+n,Cmp);
	for(int j=1,i,jj;j<=n;j++){
	  i=p[j];jj=j;
	  g=f;mx=0,mn=INF;
	  for(int k=1;k<=q;k++){
		for(;jj<=n&&(r=g.Min(p[jj]+1,n),l=g.Max(1,p[jj]-1),r-l-g.Count(l+1,r-1)<=m);jj++);
		if(jj>n)goto Brk;
		mx=std::max(mx,a[p[jj]]);
		mn=std::min(mn,a[p[jj]]);
		g.Erase(p[jj]);jj++;
	  }
	  ans=std::min(ans,mx-mn);
	  Brk:;
	  f.Update(i,i);
	}printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int N;
    cin >> N;
    int x,y,Y=0;
    for(int i=1; i <= N/15; i++){
        Y = Y+1;
    }
    x = 800*N;
    y = 200*Y;
    cout << x-y << endl;
}

Measured memory_bytes: 256
//fefe
#include<bits/stdc++.h>
//#include<inttypes.h>//__int64,__int128(?)
#define MAX_N 300005
#define MAX_M 105
//vector&pair
#define pb push_back
#define mp make_pair
#define all(V) (V).begin(),(V).end()
#define reset(V) (V).clear();(V).resize(0);
//math
#define sq(x) ((x)*(x))
#define abs(x) ((x)>0?(x):(-(x)))//Regardless of type
//for pair
#define fi first
#define se second
//infinit
#define LL_inf (1LL<<60)
#define full_inf 0x7fffffff
#define half_inf 0x3fffffff
#define inf 0x3fffffff
//MOD
#define MOD 1000000007LL
#define mod(x,m) (((x)%(m)+(m))%(m))
//operator
#define cpx_mod(x) (((LD)(((LL)x.real())%MOD)),((LD)(((LL)x.imag())%MOD)))

using namespace std;
//type
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pil;
typedef long double LD;
typedef complex<LD> Complex;
char a[MAX_N],b[MAX_N];
int main(){
	int i,j,x,y,z,n,m;
	scanf("%d %d",&n,&m);
	scanf("%s",a);scanf("%s",b);
	z=__gcd(n,m);
	x=n/z;y=m/z;
	for(i=0,j=0;i<n,j<m;i+=x,j+=y)	if(a[i]!=b[j])	return !printf("-1\n");
	printf("%lld\n",(LL)x*(LL)m);
	return 0;
}
//end

Measured memory_bytes: 384
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	H := readInt() + 2
	W := readInt() + 2
	A := make([][]byte, H)
	dist := make([][]int, H)
	for i := range A {
		A[i] = append(A[i], 'x')
		if i == 0 || i == H-1 {
			for j := 0; j < W-2; j++ {
				A[i] = append(A[i], 'x')
			}
		} else {
			A[i] = append(A[i], readBytes()...)
		}
		A[i] = append(A[i], 'x')
		dist[i] = make([]int, W)
		for j := range dist[i] {
			if A[i][j] == '#' {
				dist[i][j] = 0
			} else {
				dist[i][j] = H + W
			}
		}
	}

	for i := 1; i < H-1; i++ {
		for j := 1; j < W-1; j++ {
			dist[i][j] = min(dist[i][j], dist[i-1][j]+1)
			dist[i][j] = min(dist[i][j], dist[i][j-1]+1)
		}
	}
	for i := H - 2; 0 < i; i-- {
		for j := W - 2; 0 < j; j-- {
			dist[i][j] = min(dist[i][j], dist[i+1][j]+1)
			dist[i][j] = min(dist[i][j], dist[i][j+1]+1)
		}
	}
	var ans int
	for i := 1; i < H-1; i++ {
		for j := 1; j < W-1; j++ {
			ans = max(ans, dist[i][j])
		}
	}
	println(ans)
}

// -----------------------------------------------------------------------------


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

using namespace std;

int main(void){
//string S;
int a;
cin >> a;
int b;
cin >> b;
/*long long mincost = 0;
//vector<int> H(N);

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

sort(H.begin(), H.end(), greater<int>());

for(int i = K; i < H.size(); i++){
  mincost += H[i];
}*/
if(a <= b){
  for(int i = 0; i < b; i++){
  cout << a;
  }
  cout << endl;
}else if(a > b){
  for(int i = 0; i < a; i++){
  cout << b;
  }
  cout << endl;
}

return 0;
}


Measured memory_bytes: 256
S = input()
if "N" in S and "S" not in S:
    print("No")
elif "W" in S and "E" not in S:
    print("No")
elif "E" in S and "W" not in S:
    print("No")
elif "S" in S and "N" not in S:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 998244353;
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; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{
    set<ll, less<ll> > s;
    ll N, ans = 0;
    cin >> N;
    vector<ll> A(N);
    
    ll x = N + 1;
    rep(i, N){
        cin >> A[i];
        x = min (x, A[i]);
        if (x == A[i]){
            ans++;
        }
    }
    cout << ans;    
    return 0;    
}


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

int main()
{
  int D, G;
  cin>>D>>G;

  vector<int> p(D);
  vector<int> c(D);
  for(int i=0; i<D; i++)  cin>>p[i]>>c[i];

  int true_count=1<<30;
  for(int bit=0; bit<(1<<D); bit++){
    int sum = 0;
    int count = 0;
    for(int i=0; i<D; i++){
      if(bit&(1<<i)){
        sum += p[i]*100*(i+1) + c[i];
        count += p[i];
      }
    }
    if(sum>=G&&count<true_count)  true_count = count;
    else{
      for(int i=D-1; i>=0; i--){
        if(!(bit&(1<<i))){
          if((G-sum)<p[i]*100*(i+1)){
            while(sum<G){
              sum += 100*(i+1);
              count++;
            }
            if(true_count>count)  true_count = count;
          }
        }
      }
    }
  }
  cout<<true_count<<endl;

  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool check(string str) {
	for (auto c : str) {
		if (c == '-') {
			return false;
		}
	}

	return true;
}

bool check2(string str) {
	int cnt = 0;
	for (auto c : str) {
		if (c == '-') {
			cnt++;
		}
	}

	return cnt == 1;
}

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

	int a, b;
	string s;
	cin >> a >> b >> s;
	
	if (check(s.substr(0, a)) && check(s.substr(a + 1, b)) && check2(s)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;

int main() {
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
ll x;
  cin>>x;
  int y=x/500;
  x=x-500*y;
  int z=x/5;
  ll sum=0;
  sum=1000*y+5*z;
  cout<<sum<<endl;


  
  
}

Measured memory_bytes: 3600