akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

bool isp[100000];
vector<ll> p;
void init() {
	fill(isp+2, isp + 100000, true);
	Rep(i, 2, 100000) {
		if (!isp[i])continue;
		p.push_back(i);
		for (int j = 2 * i; j < 100000; j += i) {
			isp[j] = false;
		}
	}
}
ll mod_pow(ll x, int n, ll m) {
	x %= m;
	ll ret = 1;
	while (n) {
		if (n % 2)ret = ret * x%m;
		x = x * x%m; n >>= 1;
	}
	return ret;
}
ll Euler_t(int x) {
	ll ret = 1;
	rep(i, p.size()) {
		if (x%p[i] == 0) {
			ret *= (p[i] - 1);
			x /= p[i];
			while (x%p[i] == 0) {
				x /= p[i]; ret *= p[i];
			}
		}
	}
	if (x > 1)ret *= (x - 1);
	return ret;
}
vector<int> divis(int x) {
	vector<int> ret;
	int k = sqrt(x);
	rep1(i, k) {
		if (x%i == 0) {
			ret.push_back(i);
			ret.push_back(x / i);
		}
	}
	sort(ret.begin(), ret.end());
	ret.erase(unique(ret.begin(), ret.end()), ret.end());
	return ret;
}
ll gcd(ll x, ll y) {
	if (x < y)swap(x, y);
	while (y) {
		ll r = x % y; x = y; y = r;
	}
	return x;
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}
int main() {
	init();
	int n; cin >> n; int cop = n;
	if (n == 2) {
		cout << 1 << endl; return 0;
	}
	if (n % 2 == 0) {
		cout << -1 << endl; return 0;
	}
	bool f = true;
	vector<ll> u;
	rep(i, p.size()) {
		if (n % (p[i] * p[i]) == 0) {
			f = false; break;
		}
		if (n%p[i]==0) {
			u.push_back(p[i]); n /= p[i];
		}
	}
	if (n > 1)u.push_back(n);
	if (!f) {
		cout << -1 << endl;
	}
	else {
		ll ans = 1;
		rep(i, u.size()) {
			int r = cop / u[i];
			int z = Euler_t(u[i] - 1);
			vector<int> d = divis(z);
			int chk = -1;
			rep(j, d.size()) {
				ll s = mod_pow(r, d[j], (u[i] - 1));
				if (s == 1) {
					chk = d[j];
					break;
				}
			}
			if (chk < 0) {
				cout << -1 << endl; return 0;
			}
			ans = lcm(ans, chk);
		}
		cout << ans << endl;
	}
	//stop
	return 0;
}



Measured memory_bytes: 3372
#include <iostream>
using namespace std;
int main() {
	string str;
	while (cin >> str) {
		string res = "";
		for (int i=0; i<str.length(); i++) {
			if (str[i] == '@' && i+2 < str.length()) {
				int n = str[i+1] - '0';
				for (int j=0; j<n; j++) res += str[i+2];
				i+=2;
			} else {
				res += str[i];
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define scn(n) scanf("%d", &n)
#define scns(s) scanf("%s", &s)
#define pri(n) printf("%d", n)
#define priln(n) printf("%d\n", n)
#define pris(s) printf("%s", s)
#define prisln(s) printf("%s\n", s)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
  int n, r;
  scn(n);
  scn(r);

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

  return 0;
}


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

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

  for(i=0;i<=n-1;i++){
    min = i;
    for(j=i;j<=n-1;j++){
      if(a[j] < a[min]){
	min = j;
      }
    }
    v = a[i];
    a[i] = a[min];
    a[min] = v;
    if(i != min) cnt++;
  }

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

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



Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
int main(){
  string a,b,c;
  cin >> a >> b >> c;
  cout << (char)(a[0] - ('a'-'A')) << (char)(b[0] - ('a'-'A')) << (char)(c[0] - ('a'-'A')) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,i,j,u,k;
    cin >> n;
    int Adj[n][n];
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            Adj[i][j]=0;
    for(i=0;i<n;i++)
    {
        cin >> u >> k;
        int v[k];
        for(j=0;j<k;j++)
        {
            cin >> v[j];
            Adj[u-1][v[j]-1]=1;
        }
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n-1;j++)
        {
            cout << Adj[i][j] << ' ';
        }
        cout << Adj[i][n-1] << endl;
    }
    return 0;
}



Measured memory_bytes: 3132
from math import atan,degrees
a,b,x=map(int, input().split())
ans=None
V=(a**2)*b
if x>=V/2:
  #S=(x/a**2*b)*a*b
  #S=0.5*a*y
  #y=2S/a
  #tan(ans)=y/a
  #atan(y/a)=ans
  S=((V-x)/V)*a*b
  y=2*S/a
  ans=degrees(atan(y/a))
  #print(S, y, ans)
else:
  #S=(x/a**2*b)*a*b
  #S=0.5*b*y
  #y=2S/b
  #ans=90-atan(y/b)
  S=(x/V)*a*b
  y=2*S/b
  ans=90-degrees(atan(y/b))
  
print(ans)

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

int32_t main()
{
	int n,k;
	cin>>n>>k;
	vector<int> h(n);
	for(int i=0; i<n; i++)
		cin>>h[i];
	vector<int> dp(n,INT_MAX);
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2; i<n; i++)
	{
		for(int j=1; j<=k; j++)
		{
			if(i-j>=0)
				dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
			else
				break;
		}
	} 
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		String L = fs.next();
		int len = L.length();
		long dp[][] = new long[len][2]; //上からi桁目、未満フラグ。値は場合の数
		dp[0][0]=2;//先頭は絶対1なので 
		dp[0][1]=1;
		for(int i=1;i<len;i++) {
			int now = L.charAt(i) - '0';
			if(now == 0) {
				dp[i][0] = dp[i-1][0];
				dp[i][1] = dp[i-1][1] * 3 % mod;
			}
			else {
				dp[i][0] = dp[i-1][0]*2%mod;
				dp[i][1] = (dp[i-1][1]*3 %mod + dp[i-1][0])%mod;
			}
		}
		long ans = (dp[len-1][0] + dp[len-1][1]) % mod;
		System.out.println(ans);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 29012
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define REP(i, n) for ( int i = 0; i < (n); i++ )
 
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);

  int N;
  cin >> N;

  using P = pair<int, int>;
  vector<P> R(N), B(N);
  REP(i, N) {
    cin >> R[i].first >> R[i].second;    
  }
  REP(i, N) {
    cin >> B[i].first >> B[i].second;    
  }

  sort(B.begin(), B.end());

  int ans = 0;
  for ( int i = 0; i < N; i++ ) {
    int id = -1;
    for ( int j = 0; j < N; j++ ) {     
      if ( B[i].first > R[j].first && B[i].second > R[j].second ) {
	if ( id == -1 ) {
	  id = j;
	} else if ( R[j].second > R[id].second ) {
	  id = j;
	}
      }      
    }
    if ( id == -1 ) continue;
    // cout << i << " " << id << endl;      
    R[id].first = R[id].second = 1e9;
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3664
#include <iostream>
using namespace std;
int main(){
    int n;
    long long l[87];
    l[0]=2;
    l[1]=1;
    cin>>n;
    if(n <= 1)
        cout << l[n];
    else{
        for(int i = 2; i<=n ; ++i)
            l[i]=l[i-1]+l[i-2];
        cout << l[n];
    }
}


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

int main() {
	//Problema F
	int x;
	int y;
	cin>>x;
	cin>>y;
	if((y%2==0)&&(x*2<=y)&&(y<=x*4))
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

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

int main() {
  int k, s;
  std::cin >> k >> s;
  int c = 0;
  for (int x = 0; x < k+1; x++) {
    for (int y = 0; y < k+1; y++) {
      if (s - x - y >= 0 && s - x - y <= k) {
        c++;
      }
    }
  }
  std::cout << c << '\n';
}

Measured memory_bytes: 256
#  --*-coding:utf-8-*--


def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    B = sorted(A)
    
    m1 = B[-1]
    m2 = B[-2]

    for a in A:
        print(m1 if a != m1 else m2)



if __name__ == '__main__':
    main()


Measured memory_bytes: 14112
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 m = sc.nextInt();
		int Alist[] = new int[a];
        int Blist[] = new int[b];
        int x[] = new int[m];
        int y[] = new int[m];
        int c[] = new int[m];
        int i;
        int ans = 0;
        for(i = 0;i < a;i++){
          Alist[i] = sc.nextInt();
        }
      	for(i = 0;i < b;i++){
          Blist[i] = sc.nextInt();
        }      	
        for(i = 0;i < m;i++){
          x[i] = sc.nextInt();
          y[i] = sc.nextInt();
          c[i] = sc.nextInt();
        }
      	ans = Alist[x[0] - 1] + Blist[y[0] - 1] - c[0];
      	for(i = 1;i < m;i++){
          if(Alist[x[i] - 1] + Blist[y[i] - 1] - c[i] <= ans){
            ans = Alist[x[i] - 1] + Blist[y[i]-1] - c[i];
          }
        }
      	
        Arrays.sort(Alist);
        Arrays.sort(Blist);
        if(Alist[0] + Blist[0] < ans){
        ans = Alist[0] + Blist[0];
        }
      	
        System.out.println(ans);   
    }
}

Measured memory_bytes: 62712
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
  ll n; cin >> n;
  if(n==1){
    cout << 0 << endl;
    return 0;
  }

  ll cnt = 0;
  vector<pair<ll,int>> f;
  for(int i=2; i<=(ll)sqrt(n); i++){
    if(n%i==0){
      ll tmp = 0;
      while(n%i==0){
        n /= i;
        tmp++;
      }

      f.push_back(make_pair(i,tmp));
    }
  }

  if(n!=1) f.emplace_back(n, 1);
  for(auto p:f){
    int x = p.second;
    int b = 1;
    while(b<=x){
      x -= b;
      b++;
      ++cnt;
    }
  }


  cout << cnt << endl;
  return 0;
}


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

int main(){
    int i,n,x,sum,tsum;
    sum = 0;
    bool isBreaked = false;
    cin >> n >> x;
    for(i = 0;i<n;i++){
        cin >> tsum;
        sum += tsum;
        if(sum > x){
            cout << i+1 << endl;
            isBreaked = true;
            break;
        }
    }
    if(!isBreaked){
        cout << i+1;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
//#define num 1000000007
#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define up(a,b) (((a)%(b)==0)?((a)/(b)):((a)/(b))+1)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) (a>b)?(a>c)?a:c:(b>c)?b:c
#define min3(a,b,c) (a<b)?(a<c)?a:c:(b<c)?b:c
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define fi first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;
 
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b, a%b);
}
bool prime[3001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=3000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=3000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[20];
void power()
{
	powe[0]=1;
	REP(i,1,20)
	{
		powe[i]=(powe[i-1]*10)%num;
        if(powe[i]<0)
        powe[i]+=num;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s;
	cin>>s;
	ll len=s.size();
	string p1 = s.substr(0, len/2);
	string p2 = s.substr((len+1)/2, len/2);
	REP(i,0,p1.size())
	{
		if(p1[i]!=p1[p1.size()-1-i])
		{
			cout<<"No\n";
			exit(0);
		}
	}
	if(p1.compare(p2)==0)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>

#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 998244353

using namespace std;


void solve()
{
    int N, K, d, s;
    cin >> N >> K;

    set<int> S;

    for (int i = 0; i < K; i++)
    {
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            cin >> s;
            S.insert(s);
        }
    }

    cout << N - S.size() << endl;
}


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

    int T = 1;
    //cin >> T;
    while (T--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}



int main(){
    string s,t ;
    cin >> s >> t;
    int len = s.length();
    int ans = 0;
    rep(i,len){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}



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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> x(N), y(N);
  for (int i = 0; i < N; i++)
  {
    cin >> x[i] >> y[i];
  }
  if (N == 1)
  {
    cout << 1 << endl;
  }
  else
  {
    int res = N;
    for (int i = 0; i < N; i++)
    {
      for (int j = 0; j < N; j++)
      {
        if (i == j)
          continue;
        ll dx = x[j] - x[i], dy = y[j] - y[i];

        int sub = 0;
        for (int i2 = 0; i2 < N; i2++)
        {
          for (int j2 = 0; j2 < N; j2++)
          {
            if (i2 == j2)
              continue;
            if (dx == x[j2] - x[i2] && dy == y[j2] - y[i2])
              sub++;
          }
        }
        res = min(res, N - sub);
      }
    }
    cout << res << endl;
  }
  return 0;
}

// あるi \= jについての(xj - xi, yj - yi)についてのみ調べれば十分である．p, qを決めたらあとは，実際にN点を上手く並べることでなるべく(p, q)なジャンプが多くなるようにしたい．再び全てのi \= jについて調べることで(p, q)なジャンプが何個あるか調べればよい．ただし，N=1の場合に注意．


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;

int main(){
  int N; cin >> N;
  string S; cin >> S;
  int x = 0;
  int max = x;
  for(int i = 0; i < N; i++){
    if(S[i] == 'I') x++;
    if(S[i] == 'D') x--;
    if(x > max) max = x;
  }
  cout << max << endl;
}


Measured memory_bytes: 764
#include<stdio.h>

 int main(){
     int n,i,j,k,m[101][101],r[101],c[101],p[101],l,q;
     scanf("%d",&n);
     for(i=0;i<n;i++){scanf("%d%d",&r[i],&c[i]);}
     p[0]=r[0];
     for(i=1;i<=n;i++){p[i]=c[i-1];}

  for(i = 1 ; i <= n ; i++){m[i][i] = 0;}

     for(l=2;l<=n;l++){
             for(i=1;i<=n-l+1;i++){
                      j=i+l-1;
                      m[i][j]=1e8;
                      for(k=i;k<=j-1;k++){
                                q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
                                if(q<m[i][j])m[i][j]=q;
                                }
                      }
             }
     printf("%d\n",m[1][n]);
     return 0;
     }


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

int main()
{
    ios_base::sync_with_stdio (0);
    int A,B;
    cin >> A >> B;
    string s;
    cin>>s;
    if(s.length() != A+B+1)
        cout<<"No";
    else{
        if(s[A] == '-'){
            for(int i=0; i<s.length(); i++){
                if(i != A){
                    if(!(s[i]>='0' && s[i]<='9')){
                        cout<<"No";
                        break;
                    }
                    else if(i == s.length()-1)
                        cout<<"Yes";
                }
            }
        }
        else
            cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int n,a;
    cin >> n >> a;
    if(n%500<=a){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=2020;
char f[N][N];
int up[N][N];
int a[N],s[N],po;
int solve(int n){
    int res=0;po=0;
    for(int i=1;i<=n+1;++i){
        while(a[s[po]]>a[i]){
            int l=s[po-1]+1,r=i-1,h=a[s[po]];
            upx(res,(r-l+2)*h);
            po--;
        }
        s[++po]=i;
    }
    return res;
}
int32_t main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            cin>>f[i][j];
        }
    }
    int ans=max(n,m);
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            if(j==1)up[i][j]=0;
            else if(i==1)up[i][j]=1;
            else{
                bool mat=f[i][j]==f[i][j-1];
                bool premat=f[i-1][j]==f[i-1][j-1];
                if(mat==premat)up[i][j]=up[i-1][j]+1;
                else up[i][j]=1;
            }
            a[j-1]=up[i][j];
        }
        upx(ans,solve(m-1));
    }
    cout<<ans<<'\n';
    return 0;
}

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

int main(){
	int x,a,b,n;	cin>>x>>a>>b>>n;
	for(int i=0;i<n;i++){
		string s;	cin>>s;
		switch(s[0]){
			case 'n':
				x=max(x+a,0);
				break;
			case 't':
				x=max(x+b,0);
				break;
			case 'k':
				x=0;
				break;
		}
	}

	cout<<x<<endl;

	return 0;
}



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

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

  vector<int> vec(N);
  vec.push_back(K);
  vec.push_back(0);
  for (int i = 0; i < N; i++)
  {
    cin >> vec.at(i);
  }
  vector<int> dif(0);
  for (int i = 0; i < N; i++)
  {
    int d = vec.at(i + 1) - vec.at(i);
    dif.push_back(d);
  }
  int e = vec.at(0) - 0;
  int f = dif.at(N - 1);
  int end = e + f;
  int g = *max_element(dif.begin(), dif.end());
  int ans;
  for (int i = 0; i < N; i++)
  {
    ans += dif.at(i);
  }
  ans -= dif.at(N - 1);
  if (g <= end)
  {
    cout << ans << endl;
  }
  else
  {
    cout << end + ans - g << endl;
  }
}

Measured memory_bytes: 2828
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int 
#define pb push_back

int absoluteValue(int x){
	if(x>0)
		return x;
	return (-x);
}

using namespace std;
int T[100001];
int X[100001];
int Y[100001];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int N;
	cin>>N;
	T[0]=0;
	X[0]=0;
	Y[0]=0;
	for(int i=1;i<=N;i++)
	{
		cin>>T[i];
		cin>>X[i]>>Y[i];
	}
	int x,y,t;
	bool b=true;
	for(int i=1;i<=N;i++)
	{
		x=absoluteValue(X[i]-X[i-1]);
		y=absoluteValue(Y[i]-Y[i-1]);
		t=T[i]-T[i-1];
		if(!((x+y)<=t&&(t-(x+y))%2==0)){
			b=false;
			break;
		}
	}
	if(b){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

Measured memory_bytes: 1408
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<map>
#include<set>
using namespace std;
string s, t;
set<string> S; 
void Work()
{    int lens=s.size();
     int lent=t.size();    
     for(int i=0;i<lens;i++)    
        {        
		 if(s[i]=='?'||s[i]==t[0])        
		 {  
		 	string tmp=s;                       
	        for(int j=0;j<i;j++)               
		        if(tmp[j]=='?')                    
			     tmp[j]='a';                
	      
           bool can=false;            
	       for(int j=0;j<lent;j++)        
		   { 
		      if(tmp[i+j]!='?'&&tmp[i+j]!=t[j])                   
		             break; 
	           tmp[i+j]=t[j];                
		       if(j==lent-1) 
				   can=true;            
		 }            
	     if(can)  { 
		   for(int j=i+lent;j<lens;j++) 
			   if(tmp[j]=='?') 
				   tmp[j]='a';              
		    S.insert(tmp);            
		   }       
		 }   
		 }    
	 if(S.size()==0) cout<< "UNRESTORABLE"<<endl;    
	    else 
	    		cout<<*S.begin();
	}
int main(){    
	cin>>s>>t;    
	Work();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

struct point {
    ll next;
    ll cost;
};
bool operator<(const point& l, const point& r) {
    return l.next < r.next;
}
bool operator==(const point& l, const point& r) {
    return (l.next == r.next);
}
bool operator>(const point& l, const point& r) {
    return !(l == r) && !(l < r);
}
bool operator!=(const point& l, const point& r) {
    return !(l == r);
}
bool operator>=(const point& l, const point& r) {
    return (l == r) || (l > r);
}
bool operator<=(const point& l, const point& r) {
    return (l == r) || (l < r);
}

int main() {
    ll N, K;

    cin >> N >> K;
    vector<point> points(N + 1);

    for (ll i = 1; i <= N; i++) {
        cin >> points[i].next;
    }
    ll INF = 100000000000000;
    bool plus_exist = false;

    for (ll i = 1; i <= N; i++) {
        cin >> points[i].cost;
        if (points[i].cost > 0) {
            plus_exist = true;
        }
    }
    if (!plus_exist) {
        ll max_cost = -INF;
        for (ll i = 1; i <= N; i++) {
            max_cost = max(max_cost, points[i].cost);
        }
        print(max_cost);
        return 0;
    }

    map<ll, vector<ll>> unions;
    vector<pair<ll, ll>> isshu_costs;
    set<ll> done;

    for (ll i = 1; i <= N; i++) {
        if (done.count(i)) {
            continue;
        }

        ll cst = 0;
        point p = points[i];
        done.insert(i);
        while (true) {
            cst += points[p.next].cost;
            done.insert(p.next);
            unions[i].push_back(p.next);
            if (p.next == i) {
                break;
            }
            p = points[p.next];
        }
        isshu_costs.push_back(make_pair(i, cst));
    }

    ll max_result = -INF;
    for (auto ic : isshu_costs) {
        ll cost = ic.second;
        ll i = ic.first;
        ll size = unions[i].size();
        ll ic_result = 0;
        ll RK = -1;
        if (cost > 0 && K >= 2 * size) {
            ll shu = K / size - 1;
            ic_result += shu * cost;
            RK = K - shu * size;
        } else if (cost <= 0) {
            RK = min(size, K);
        } else {
            RK = K;
        }
        ll max_move = -INF;
        for (ll s : unions[i]) {
            ll total = 0;
            point pp = points[s];
            for (ll j = 0; j < RK; j++) {
                total += points[pp.next].cost;
                pp = points[pp.next];
                max_move = max(total, max_move);
            }
        }
        if (max_move != -INF) {
            ic_result += max_move;
        }
        max_result = max(max_result, ic_result);
    }
    print(max_result);
}


Measured memory_bytes: 3996
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);
		while(s.hasNext()){
			String a=s.next();
			String b=s.next();
			if(a.length()>b.length()){
				String c=a;
				a=b;
				b=c;
			}
			int ret=0;
			for(int i=0;i<a.length();i++){
				int now=0;
				int temp=0;
				for(int j=0;j<a.length()&&j+i<b.length();j++){
					if(a.charAt(j)==b.charAt(j+i))temp++;
					else{
						now=Math.max(now,temp);
						temp=0;
					}
				}
				now=Math.max(now,temp);
				ret=Math.max(now,ret);
				//System.out.println(now);
			}
			String d=a;
			a=b;
			b=d;
			for(int i=0;i<a.length();i++){
				int now=0;
				int temp=0;
				for(int j=0;j<a.length()&&j+i<b.length();j++){
					if(a.charAt(j)==b.charAt(j+i))temp++;
					else{
						now=Math.max(now,temp);
						temp=0;
					}
				}
				now=Math.max(now,temp);
				ret=Math.max(now,ret);
				//System.out.println(now);
			}
			
			System.out.println(ret);
		}
	}
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

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


    cout << 3 * r*r <<endl;
    return (0);
}

Measured memory_bytes: 256
import numpy as np

n,m=map(int,input().split())
x=list(map(int,input().split()))
n = min(n,len(x))

xs=sorted(x)
# xs

# def sabun(x,i):
#     return x[i+1]-x[i]

def sabun(x):
    a=np.array(x)
    return list(a[1:]-a[:-1])

# sabunx=[sabun(xs,i) for i in range(m-1)]

sabunx=sabun(xs)
# sabunx

print(sum(sorted(sabunx,reverse=True)[n-1:]))

Measured memory_bytes: 22972
#include <iostream>

using namespace std;

void insertionSort(int*, int);
void trace(int*, int);

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

void trace(int a[], int n){
  for(int i = 0; i < n; i++){
    if(i>0) cout << " ";
    cout << a[i];
  }
  cout << endl;
}

int main(){
  int n;
  int a[100];

  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  trace(a, n);
  insertionSort(a, n);
  return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>

int main()
{
	int N;
	scanf("%d", &N);
	
	int i;
	long long ans = 0;
	for (i = 1; i <= N; i++) ans += (long long)(N / i) * (N / i + 1) * i / 2;
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1712
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.function.Supplier;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int tVertex = scanner.nextInt();
        final int aVertex = scanner.nextInt();

        final List<Integer>[] tree = new List[n + 1];
        for (int i = 1; i < tree.length; i++) {
            tree[i] = new ArrayList<>();
        }
        for (int i = 0; i < n - 1; i++) {
            final int a = scanner.nextInt();
            final int b = scanner.nextInt();
            tree[a].add(b);
            tree[b].add(a);
        }

        final List<Integer> route = new ArrayList<>();
        final boolean[] isVisited = new boolean[n + 1];
        search(tree, aVertex, tVertex, route, isVisited);

        Arrays.fill(isVisited, false);
        final int upper = (route.size() - 1) / 2;
        for (int i = 0; i < upper; i++) {
            isVisited[route.get(i)] = true;
        }
        if (upper + 1 < route.size()) {
            final int selectable = route.get(upper + 1);
            for (final int vertex : tree[route.get(upper)]) {
                if (vertex == selectable) {
                    continue;
                }
                isVisited[vertex] = true;
            }
        }

        final int longestDistance = searchLongest(tree, route.get(upper), 0, isVisited);

        System.out.println(longestDistance + upper - 1);
    }

    private static int searchLongest(final List<Integer>[] tree, final int current, final int distance, final boolean[] isVisited) {
        isVisited[current] = true;
        int longest = distance;
        for (final int next : tree[current]) {
            if (isVisited[next]) {
                continue;
            }

            final int tmp = searchLongest(tree, next, distance + 1, isVisited);
            if (tmp > longest) {
                longest = tmp;
            }
        }
        return longest;
    }

    private static boolean search(final List<Integer>[] tree, final int current, final int dest, final List<Integer> route, final boolean[] isVisited) {
        isVisited[current] = true;
        route.add(current);
        if (current == dest) {
            return true;
        }
        for (final int next : tree[current]) {
            if (isVisited[next]) {
                continue;
            }

            if (search(tree, next, dest, route, isVisited)) {
                return true;
            }
        }
        route.remove(route.size() - 1);
        return false;
    }
}


Measured memory_bytes: 110792
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define ZERO(a) memset(a,0,sizeof(a))

int n,m;
int A[111][111];
int b[111];

int main() {
    cin >> n >> m;
    ZERO(A); ZERO(b);
    rep(i,n) rep(j,m) cin >> A[i][j];
    rep(i,m) cin >> b[i];

    rep(i,n) {
        int c = 0;
        rep(j,m) c += A[i][j] * b[j];
        cout << c << endl;
    }

    return 0;
}

Measured memory_bytes: 1220
import math

#print(math.pi)

A, B, H, M = map(int, input().split())

rad = 2 * math.pi * ((H / 12 + M / (60 * 12)) - M / 60)
ans = math.sqrt(A ** 2 + B ** 2 - (2 * A * B * math.cos(rad)))

print(ans)


Measured memory_bytes: 9496
#include <stdio.h>

int main()
{
  int n;
  scanf("%d", &n);
  long long int N[n], max = 1e18, prod = 1, flag = 0, zero = 0;
  
  for (int i = 0; i < n; i++)
  {
    scanf("%lld", &N[i]);
    flag = (N[i] > max) ? 1 : flag;
    prod *= N[i];
    (N[i]) ? max /= N[i] : zero = 1;
  }

  (zero) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));
  return 0;
}

Measured memory_bytes: 4020
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll xum = 0;
  ll a[N];
  for(int i=0;i<N;++i) {
    cin>>a[i];
    xum ^= a[i];
  }
  for(int i=0;i<N;++i) cout<<(xum^a[i])<<" ";
  cout<<endl;
}



Measured memory_bytes: 5096
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
int N;
vector<string> v;
/* function */
void rec(int n, string s) {
    if (s.size() == N) {
        v.push_back(s);
        return ;
    }
    for (int i = 1; i <= n+1; i++) {
        string t;
        t += static_cast<char>('a' + i - 1);
        rec((i == n+1) ? n+1 : n, s + t);
    }
}
/* main */
int main(){
    cin >> N;
    rec(1, "a");
    sort(v.begin(), v.end());
    for (string s : v) cout << s << '\n';
}


Measured memory_bytes: 7796
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int maxp = 0;
  int wap = 0;
  int p[10000];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> p[i];
    maxp = max(maxp,p[i]);
    wap = wap + p[i];
  }
  cout << wap - maxp/2 << endl;
}


Measured memory_bytes: 256
# coding: utf-8
from functools import reduce

n = int(input())

camels = list(map(int, input().split()))

# 全ての帽子に書かれた数が 0
if all(map(lambda x: x == 0, camels)):
    print('Yes')
# x が書かれた帽子が 2N/3枚、0 が書かれた数が N/3 枚
elif n % 3 == 0 and len(set(camels)) == 2 and camels.count(0) == n // 3:
    print('Yes')
# x ⊕ y ⊕ z = 0 が成立するような 3 つの相異なる整数 x, y, z が書かれた帽子がそれぞれ N/3 枚
elif n % 3 == 0 and len(set(camels)) == 3 \
        and reduce(lambda x, y: x ^ y, set(camels)) == 0 \
        and camels.count(sorted(set(camels))[0]) == n // 3 \
        and camels.count(sorted(set(camels))[1]) == n // 3:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 14708
A, B, C, X, Y = map(int, input().split())
if A + B >= C * 2:
    price = min(X, Y) * C * 2
    tmp = min(X,Y)
    X = X - tmp
    Y = Y - tmp
    if A * X < C * X * 2:
        price += A * X
        X -= X
    if B * Y < C * Y * 2:
        price += B * Y
        Y -= Y
    price += C * 2 * max(X, Y)
    print(price)

else:
    print(A * X + B * Y)

Measured memory_bytes: 3064
n,m=map(int,input().split())
p=list(map(int,input().split()))
l=[]
for i in range(m):
    x,y=map(int,input().split())
    l.append([x,y])

class UnionFind:
    def __init__(self,n):
        self.par=[i for i in range(n)]
        self.rank=[0]*(n)
    def find(self,x):
        if self.par[x]==x:
            return x
        else:
            self.par[x]=self.find(self.par[x])
            return self.par[x]
    def same_check(self,x,y):
        return self.find(x)==self.find(y)
    def union(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if self.rank[x]<self.rank[y]:
            self.par[x]=y
        else:
            self.par[y]=x
            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1

uf=UnionFind(n)

for a,b in l:
    uf.union(a-1,b-1)

num=0
for i in range(n):
    num+=uf.same_check(i,p[i]-1)
print(num)


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    ll n,m;cin>>n>>m;
    vl a;
    if(n==1){
        cout<<m<<endl;
        return 0;
    }
    for(int i=1;i*i<=m;++i){
        if(m%i==0){
            a.PB(i);
            if(m/i!=i)a.PB(m/i);
        }
    }
    sort(all(a));
    rep(i,a.size()){
        if(a[i]>=n){
            cout<<m/a[i]<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
vector<int> v[1010];
vector<pair<int,int>> u;
int main(){
	int i,j,h,w;
	cin >> h >> w;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			char c; cin >> c;
			if(c=='B'){
				v[i].push_back(j);
			}
		}
	}
	for(i=0;i<h;i++){
		sort(v[i].begin(),v[i].end());
	}
	for(i=0;i<h;i++){
		if(v[i].size()>=1){
			u.push_back({i,v[i][0]});
			u.push_back({i,v[i].back()});
		}
	}
	int mx = 0;
	for(i=0;i<u.size();i++){
		for(j=0;j<u.size();j++){
			mx = max(mx,abs(u[i].first - u[j].first) + abs(u[i].second - u[j].second));
		}
	}
	cout << mx << endl;
}


Measured memory_bytes: 6576
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  n%=m;
  pr(min(n,m-n));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
import sys


#input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')


def main():
	n=II()
	s=input()
	ss=s
	for _ in range(100):
		s=s.replace("()","")
	ans="("*s.count(")")+ss+")"*s.count("(")
	print(ans)
	
	
	





	

if __name__=="__main__":
	main()


Measured memory_bytes: 9128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)



int main() {
	vector<int>A(32);
	A = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int K;
	cin >> K;
	cout << A[K - 1] << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int a[101],n;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int ans=1;
    for(int i=2;i<=n;i++)
        {
           int flag=0;

        for(int j=1;j<=i-1;j++)
            if (a[j]>a[i]) flag=1;
        if (flag==0) ans++;
        }
    cout <<ans<< endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    int x[105];
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += min(x[i]*2, (k-x[i])*2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	array := make([]int, n)
	var max = 0
	var max2 = 0
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		if max == a {
			max2 = a
		}
		if max < a {
			max = a
		}
		if a != max && a > max2 {
			max2 = a
		}

		array[i] = a
	}
	for _, N := range array {
		if N == max {
			fmt.Println(max2)
		} else {
			fmt.Println(max)
		}
	}
}


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

// マクロ //
#define rep(v,times) for(int v = 0; v < (int)(times); v++)
#define req(v,first,endplus1) for(int v = first; v < (int)(endplus1); v++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using plili = pair<lint, lint>;
using vplili = vector<plili>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd_(a, b);
}

template<class T, class Q> double distance(T a, Q b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);
const int dx4[4] = { 1,0,-1,0 };
const int dy4[4] = { 0,1,0,-1 };
const int dx8[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy8[8] = { 0,1,1,1,0,-1,-1,-1 };

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    lint A;
    double B;
    lint longB;
    cin >> A >> B;
    B *= 100;
    longB = round(B);
    cou(A * longB / 100);
}

Measured memory_bytes: 3800
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_set>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; ++i)

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int N; cin >> N;	// N <= 2e5
	vector<char> cs(N);
	int rNum = 0;
	REP(i, N)
	{
		cin >> cs[i];
		if (cs[i] == 'R') ++rNum;
	}
	int wNum = N - rNum;
	int swapRedNum = 0;
	REP(i, rNum)
	{
		if (cs[i] == 'W') ++swapRedNum;
	}
	cout << swapRedNum << endl;
}

Measured memory_bytes: 3628