akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
// http://drken1215.hatenablog.com/entry/2019/05/19/230600

void solve(int M, int K) {
    if(M == 0) {
        if(K != 0) {
            cout << -1 << endl;
        } else {
            cout << "0 0" << endl;
        }
        return;
    } else if(M == 1) {
        if(K != 0) {
            cout << -1 << endl;
        } else {
            cout << "0 0 1 1" << endl;
        }
        return;
    }
    if(K >= (1 << M)) {
        cout << -1 << endl;
        return;
    }
    if(K == 0) {
        for(int bit = 0; bit < (1 << M); bit++) {
            cout << bit << " ";
        }
        for(int bit = (1 << M) - 1; bit >= 0; bit--) {
            cout << bit << " ";
        }
        cout << endl;
        return;
    }
    using pint = pair<int, int>;
    vector<pint> v;
    for(int bit = 0; bit < (1 << M); bit++) {
        v.push_back(pint(min(bit, bit ^ K), max(bit, bit ^ K))); // bit xor
    } //小さいのと大きいののペア
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),
            v.end()); //ほんとに重複有るのかなって思うけど
    for(int i = 0; i < v.size(); i += 2) {
        cout << v[i].first << " " << v[i].second << " " << v[i + 1].first << " "
             << v[i + 1].second << " " << v[i].second << " " << v[i].first
             << " " << v[i + 1].second << " " << v[i + 1].first << " ";
    }
    cout << endl;
}

int main() {
    int M, K;
    cin >> M >> K;
    solve(M, K);
}

Measured memory_bytes: 2932
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll H,W; cin>>H>>W;
  vector<string> grid(H); rep(i,H) cin>>grid[i];
  vector<vector<ll>> memo(H,vector<ll>(W,INF));
  
  auto movable=[&](ll gx,ll gy){
    if(gx<0||gx>=W||gy<0||gy>=H) return false;
    if(grid[gy][gx]=='#') return false;
    if(memo[gy][gx]<INF) return false;
    
    return true;
  };
  
  //bfs
  queue<pair<ll,ll>> que;
  que.push({0,0}); memo[0][0]=1;
  while(!que.empty()){
    auto p=que.front(); que.pop();
    ll x,y; tie(x,y)=p;
    rep(i,4){
      ll nx=x+dx[i],ny=y+dy[i];
      if(movable(nx,ny)){
        memo[ny][nx]=memo[y][x]+1;
        que.push({nx,ny});
      }
    }
  }
  
  ll black=0; rep(y,H) rep(x,W) if(grid[y][x]=='#') black++;
  
  if(memo[H-1][W-1]==INF) cout<<-1<<endl;
  else cout<<H*W-memo[H-1][W-1]-black<<endl;
  
  return 0;
}

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


int main(){
  int n,i;
  cin >> n;
  map<int,int> mp;
  for(i=0;i<n;++i){
    int a;
    cin >> a;
    mp[a]++;
    mp[a-1]++;
    mp[a+1]++;
  }
  int ans=0;
  for(auto p : mp){
    ans=max(ans,p.second);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int A,B,X;
    cin >> A >> B >> X;
    if((A<=X)&&(X<(A+B))){
        cout << "YES"<< endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

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

int main()
{
  int A, B, K;
  int cnt=0;
  cin >> A >> B >> K;

  for(int i=100; i>=1;i--){
    int a = A % i;
    int b = B % i;
    if(a==0 && b==0) cnt++;
    if(cnt == K) {
      cout << i << endl;
      return 0;
    }
  }

}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
   int x=sc.nextInt(),a=sc.nextInt(),b=sc.nextInt();
    String taste="";
    if(b<=a){
      taste="delicious";
    }else if(a+x>=b){
      taste="safe";
    }else{
      taste="dangerous";
    }
    System.out.println(taste);
  }
}

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

int main() {
	long double n, m, d; cin >> n >> m >> d;
	double ans = (1.0) * (n - d) * (d == 0 ? 1 : 2) * (m - 1) / n / n;
	printf("%10f\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	string S;
	cin >> S;
	if(S == "zyxwvutsrqponmlkjihgfedcba") cout << -1 << endl;
	else{
		if(S.size() == 26){
			set<char> st;
			st.insert(S[25]);
			for(int i=24; i>=0; i--){
				auto itr = st.upper_bound(S[i]);
				if(itr != st.end()){
					cout << S.substr(0,i) << *itr << endl;
					break;
				}
				st.insert(S[i]);
			}
		}
		else{
			bool c[26] = {};
			for(int i=0; i<S.size(); i++){
				c[S[i]-'a'] = true;
				
			}
			cout << S;
			for(int i=0; i<26; i++){
				if(c[i] == false){
					cout << (char)('a'+i) << endl;
					break;
				}
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    int n;
    cin >> n;
    vector<int>t(n+1);
    vector<int>x(n+1);
    vector<int>y(n+1);
    rep(i,n) {
        cin >> t[i] >> x[i] >> y[i];
    }
    bool ans = true;
    rep(i,n) {
        int dt = abs(t[i]-t[i+1]);
        int dx = abs(x[i]-x[i+1]);
        int dy = abs(y[i]-y[i+1]);
        if(dt < dx+dy || dt%2 != (dx+dy)%2) {
            ans = false;        
            break;
        }          
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int GCD(int a,int b){
  while(a){
    swap(a,b%=a);
  }
  return b;
} 
int main(){
  int n,x,g;
  cin>>n>>x;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    g=GCD(abs(x-a[i]),g);
  }
  cout<<g;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

const double PI = 3.14159265358979;

class Point {
public:
    double x, y;
    Point(double x = 0.0, double y = 0.0) :x(x), y(y) {}
};

class Wind {
public:
    double w, a;
};

bool include(double angle, double low, double high) {
    if(low < 0.0 && low + 2.0 * PI <= angle) return true;
    if(high >= 2.0 * PI && angle <= high - 2.0 * PI) return true;
    return low <= angle && angle <= high;
}

bool savor(const Point &home, const Wind &wind, const vector<Point> &blossom, double d) {
    d /= 2.0;
    for(const auto &b: blossom) {
        Point dif(home.x - b.x, home.y - b.y);
        double angle = atan2(dif.y, dif.x);
        double dist = hypot(dif.y, dif.x);
        if(angle < 0.0) angle = angle + 2.0 * PI;
        if(dist <= wind.a && include(angle, wind.w - d, wind.w + d)) return true;
    }
    return false;
}

double toRadian(double d) {
    return d * PI / 180.0;
}

int main() {
    int H, R;
    while(cin >> H >> R, H | R) {
        vector<Point> home(H);
        for(auto &i: home) cin >> i.x >> i.y;

        int U, M, S;
        double du, dm, ds;
        cin >> U >> M >> S >> du >> dm >> ds;

        du = toRadian(du);
        dm = toRadian(dm);
        ds = toRadian(ds);

        vector<Point> plum(U), peach(M), cherry(S);
        for(auto &i: plum) cin >> i.x >> i.y;
        for(auto &i: peach) cin >> i.x >> i.y;
        for(auto &i: cherry) cin >> i.x >> i.y;

        vector<Wind> wind(R);
        for(auto &i: wind) cin >> i.w >> i.a;
        for(auto &i: wind) i.w = toRadian(i.w);

        // solve
        vector<int> number(H, 0);
        int maxNumber = 0;

        for(int i = 0; i < H; ++i) {
            for(int day = 0; day < R; ++day) {
                bool ok = savor(home[i], wind[day], {Point(0.0, 0.0)}, du);
                bool ng = false;
                ng |= savor(home[i], wind[day], plum, du);
                ng |= savor(home[i], wind[day], peach, dm);
                ng |= savor(home[i], wind[day], cherry, ds);

                if(!ok || ng) continue;

                ++number[i];
                maxNumber = max(maxNumber, number[i]);
            }
        }

        if(maxNumber) {
            bool first = true;
            for(int i = 0; i < H; ++i) if(number[i] == maxNumber) {
                if(!first) cout << " ";
                first = false;
                cout << i + 1;
            }
            cout << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 1332
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#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 REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n,q; string s; cin>>n>>s>>q;
	vector<set<int>> cnt;
	cnt.assign(26, set<int>({INF}));
	rep(i,n) cnt[s[i]-'a'].insert(i);

	rep(_,q){
		int type; cin>>type;
		if(type==1){
			int i; char c; cin>>i>>c; i--;
			cnt[s[i]-'a'].erase(i);
			s[i]=c; cnt[s[i]-'a'].insert(i);
		}else{
			int l,r; cin>>l>>r; l--;
			int ans=0;
			rep(c,26){
				if(cnt[c].empty()) continue;
				int lidx=*cnt[c].lower_bound(l);
				int ridx=*cnt[c].lower_bound(r);
				if(ridx>lidx) ans++;
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 24220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	int n,q;
	cin >> n >> q;
	vector<vector<int>> ki(n);
	vector<pair<int,int>> pv(q);
	rep(i,n-1)
	{
		int a,b;
		cin >> a >> b;
		a--;b--;
		ki[a].push_back(b);
		ki[b].push_back(a);
	}
	rep(i,q)
	{
		int p,x;
		cin >> p >> x;
		p--;
		pv[i] = make_pair(p,x);
	}
	vector<int> G(n);
	rep(i,q)
	{
		G[pv[i].first] += pv[i].second;
	}
	stack<int> S;
	S.push(0);
	vector<int> color(n,-1);
	color[0] = 0;
	while(!S.empty())
	{
		int now = S.top();
		S.pop();
		rep(i,ki[now].size())
		{
			if(color[ki[now][i]]==-1)
			{
				S.push(ki[now][i]);
				G[ki[now][i]]+=G[now];
				color[ki[now][i]] = 0;
			}
		}
	}
	rep(i,n)
	{
		cout<<G[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;
int32_t main()
{
	IOS;
	int n;
	cin>>n;
	int i,arr[n];
	int mx=-1;
	map<int,int>m;
	for(i=0;i<n;i++)
	{
		cin >> arr[i];
		mx=max(mx,arr[i]);
		m[arr[i]]++;
	}

	sort(arr,arr+n);
	bool dp[mx+1];
	memset(dp,true,sizeof(dp));
	for(i=0;i<n;i++)
	{
		if(!dp[arr[i]]) continue;
		for(int h=2;arr[i]*h<=mx;h++)
		dp[arr[i]*h]=false;
	}
	int cnt=0;
	for(i=0;i<n;i++)
	{
		if(dp[arr[i]] && m[arr[i]]<2) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 18648
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(10)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }

class vec2d {
public:
	double x, y;
	vec2d(double x, double y) :x(x), y(y) {}
	double norm() const {
		return sqrt(x * x + y * y);
	}
	vec2d operator+(vec2d v) {
		return vec2d(x + v.x, y + v.y);
	}
	vec2d operator-(vec2d v) {
		return vec2d(x - v.x, y - v.y);
	}
	vec2d operator*(double k) const {
		return vec2d(x * k, y * k);
	}
	vec2d operator/(double k)const {
		return vec2d(x / k, y / k);
	}
	static double inner_product(const vec2d&a, const vec2d&b) {
		return a.x * b.x + a.y * b.y;
	}
	static double cros_product(const vec2d&a, const vec2d&b) {
		return a.x * b.y - a.y * b.x;
	}
	static double argument(const vec2d&a, const vec2d&b) {
		return atan2(cros_product(a, b), inner_product(a, b));
	}
	static vec2d projection(const vec2d&a, const vec2d&b) {
		double n = a.norm();
		return a * vec2d::inner_product(a, b) / n / n;
	}
};
signed main() {
	SETP;
	int xp0 = in(), yp0 = in(), xp1 = in(), yp1 = in();
	vec2d a(xp1 - xp0, yp1 - yp0);
	int q = in();
	REP(i, q) {
		int xp2 = in(), yp2 = in();
		vec2d b(xp2 - xp0, yp2 - yp0);
		double arg = vec2d::argument(a, b);
		if (abs(arg) < EPS) {
			if (a.norm() < b.norm()) {
				cout << "ONLINE_FRONT" << endl;
			} else {
				cout << "ON_SEGMENT" << endl;
			}
		} else if (abs(abs(arg) - M_PI) < EPS) {
			cout << "ONLINE_BACK" << endl;
		} else if (arg > 0) {
			cout << "COUNTER_CLOCKWISE" << endl;
		} else if (arg < 0) {
			cout << "CLOCKWISE" << endl;
		}
	}
}


Measured memory_bytes: 3404
import java.util.Scanner;

public class Main {

	public static void main(String args[]){
		Scanner cin = new Scanner(System.in);

		int A = cin.nextInt();
		int B = cin.nextInt();
		int C = cin.nextInt();
		cin.close();
		String result;
		if((A*100+B*10+C)%4==0){
			result = "YES";
		}else{
			result = "NO";
		}

		System.out.println(result);
	}
}


Measured memory_bytes: 24916
x,y = map(int, input().split())
if x < 0 and y < 0:
    if abs(x) < abs(y):
        print(abs(x-y)+2)
    else:
        print(abs(x-y))
elif x > 0 and y > 0:
    if abs(x) > abs(y):
        print(x-y+2)
    else:
        print(y-x)

elif x < 0 and y > 0:
    print(abs(y+x)+1)
elif x > 0 and y < 0:
    print(abs(y+x)+1)
elif x > 0 and y == 0:
    print(x+1)
elif x < 0 and y == 0:
    print(-x)
elif x == 0 and y == 0:
    print(0)
elif x == 0 and y < 0:
    print(-y + 1)
elif x == 0 and y > 0:
    print(y) 




Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#pragma warning(disable : 4996)
 
int main()
{
 
    long long a, b, x;
    long long count = 0;
 
    scanf("%lld %lld %lld", &a, &b, &x);
 
    long long ai = a / x;
    long long bi = b / x;
 
    long long start, goal;
 
    if (ai * x == a)
        start = ai;
    else
        start = ai + 1;
 
    goal = bi;
 
    printf("%lld", goal - start + 1);
 
 
    return 0;
 
}

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

int main(){
    map<string, int> add, sub;

    int n; cin >> n;
    vector<string> s(n);
    for(int i=0; i<n; i++){
        cin >> s[i];
        add[s[i]]++;
    }
    int m; cin >> m;
    vector<string> t(m);
    for(int i=0; i<m; i++){
        cin >> t[i];
        sub[t[i]] ++;
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        int tmp = add[s[i]] - sub[s[i]];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}    

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
	ll n;
	cin>>n;
	ll a[n];
	ll ans = 0;
	for(int i=0;i<n;i++) {
		cin>>a[i];
	}
	for(int i=0;i<n;i++) {
		ans += a[i]/2;
		if(i+1 < n && (a[i]&1) && a[i+1] != 0) {
			a[i+1] --;
			ans ++;
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

typedef complex<int> P;

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

// ?????°??? ??? ??§??????
double deg2rad(double x) {return x * M_PI / 180.0;}

// ??? a ???????????¨???????????? b ??? z ????????¢???????????¨????????????
P rotatePoint(P a, P b, double z) {
    // ?????°????????´????????????
    z = deg2rad(z);

    b -= a;
    double rx = b.X * cos(z) - b.Y * sin(z);
    double ry = b.X * sin(z) + b.Y * cos(z);
    P ret(rx, ry); ret += a;
    return ret;
}

int calcdeg(int x, int y) {
    if(x == 0) return y > 0 ? 0 : 2;
    else return x > 0 ? 1 : 3;
}

vector<P> convertLine(vector<P> v) {
    int n = v.size(), deg = 0;
    P prev = P(0, 0);
    vector<P> ret;
    ret.push_back(prev);
    rep(i,0,n-1) {
        int sx = v[i+1].X - v[i].X;
        int sy = v[i+1].Y - v[i].Y;
        // printf("sx = %lf, sy = %lf\n", sx, sy);

        if(i == 0) {
            int temp = calcdeg(sx, sy);
            deg = temp;
        }
        P aft = rotatePoint(P(0, 0), P(sx, sy), 90 * deg);
        ret.push_back(aft + prev);
        prev = aft + prev;
    }
    return ret;
}

int N, M;
signed main() {
    while(cin >> N, N) {
        vector<P> orig;
        cin >> M;
        rep(i,0,M) {
            double x, y; cin >> x >> y;
            orig.push_back(P(x, y));
        }
        orig = convertLine(orig);

        vector<int> ans;
        rep(i,0,N) {
            vector<P> ls;
            cin >> M;
            rep(j,0,M) {
                double x, y; cin >> x >> y;
                ls.push_back(P(x, y));
            }

            vector<P> temp = convertLine(ls);
            if(orig == temp) {
                ans.push_back(i+1);
                continue;
            }

            reverse(ls.begin(), ls.end());
            temp = convertLine(ls);
            if(orig == temp) {
                ans.push_back(i+1);
                continue;
            }
        }

        rep(i,0,ans.size()) cout << ans[i] << endl;
        printf("+++++\n");
    }
    return 0;
}

Measured memory_bytes: 3352
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i,a,b) for(int i=a;i<=b;i++)
const int N=1e2+5;
int n,m,k,l,r;
int f[N],g[N];
char a[N][N];
int main()
{
	cin>>n>>m;
	rep(i,1,n)cin>>a[i]+1;
	rep(i,1,n)rep(j,1,m)
	{
		if(a[i][j]=='#')f[i]=g[j]=1;
	}
	rep(i,1,n)if(f[i]){rep(j,1,m)
	{
		if(g[j])cout<<a[i][j];

	}cout<<endl;}
}


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

using namespace std;
int main()
{
    long long n,m;
    cin >> n >> m;
    long long ara[n];
    for(long long i=0; i<n; i++){
        cin >> ara[i];
    }
    sort(ara, ara+n);
    n-=m;
    long long sum=0;
    for(long long i=0; i<n; i++){
        sum+=ara[i];
    }
    cout << sum;
}

Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,m,q; cin>>n>>m;
    vector<vector<int>> path(n),dp(n,vector<int>(11,0));
    rep(i,m){
        int a,b; cin>>a>>b;
        a--; b--;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    cin>>q;
    vector<vector<int>> Q(q,vector<int>(3,0));
    rep(i,q)rep(j,3){
        cin>>Q[i][j];
        if(j==0) Q[i][j]--;
    }
    int v,d;
    for(int i=q-1;i>=0;i--){
        queue<pp> que;
        v=Q[i][0]; d=Q[i][1];
        if(d==0){
            if(dp[v][d]==0) dp[v][d]=Q[i][2];
            continue;
        }
        if(dp[v][d]==0){
            dp[v][d]=Q[i][2];
            que.push(mk(v,d));
        }
        while(!(que.empty())){
            int u,k;
            tie(u,k)=que.front();
            que.pop();
            if(dp[u][k-1]==0){
                dp[u][k-1]=Q[i][2];
                if(k>1) que.push(mk(u,k-1));
            } 
            for(auto to:path[u]){
                if(dp[to][k-1]==0){
                    dp[to][k-1]=Q[i][2];
                    if(k>1) que.push(mk(to,k-1));
                }
            }
        }
    }
    rep(i,n) printf("%d\n",dp[i][0]);
}

Measured memory_bytes: 21784
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <list>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

#define xx first
#define yy second
#define $1 first
#define $2 second

void solveCase() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n, m; cin >> n >> m;
	cout << (n + m)*(n + m - 1) / 2 - n*m;

}

int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solveCase();
}

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

signed main(){
    int s,w;cin>>s>>w;
    if(s<=w) cout<<"unsafe"<<endl;
    else  cout<<"safe"<<endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
typedef pair<double,int> Pdi;
int n;
int main(int argc,char const* argv[])
{
  while(1)
    {
      cin >> n;
      if(!n) break;
      vector<string> s(n);
      for(int i=0;i<n;i++)
	{
	  cin >> s[i];
	}
      bool clear=false;
      for(int k=1;k<=50;k++)
	{
	  clear=true;
	  vector<string> tmp(n);
	  set<string> st;
	  for(int i=0;i<n;i++)
	    {
	      tmp[i]="";
	    }
	  for(int i=0;i<n;i++)
	    {
	      tmp[i]=tmp[i]+s[i][0];
	      for(int j=0;j<s[i].size()-1;j++)
		{
		  if(s[i][j]=='a' || s[i][j]=='i' || s[i][j]=='u' || s[i][j]=='e' || s[i][j]=='o')
		    {
		      tmp[i]=tmp[i]+s[i][j+1];
		    }
		}
	      if(tmp[i].size()>k)
		{
		  tmp[i]=tmp[i].substr(0,k);
		}
	      auto itr=st.find(tmp[i]);
	      if(itr!=st.end()) 
		{
		  clear=false;
		  break;
		}
	      else
		{
		  st.insert(tmp[i]);
		}
	    }
	  if(clear)
	    {
	      cout << k << endl;
	      break;
	    }
	}
      if(!clear) cout << -1 << endl;
    }
  return 0;
}



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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	int n;
	cin >> n;
	vector<pair<pair<string, int>,int>> score(n);
	repz(i, n) {
		cin >> score[i].first.first >> score[i].first.second;
		score[i].first.second *= -1;
		score[i].second = i + 1;
	}

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

	repz(i, n)cout << score[i].second << endl;	

	system("pause");
	return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll N;
    cin>>N;
    cout<<"ABC"<<N<<endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    A=list(map(int,input().split()))
    B=[(A[i],i) for i in range(N)]
    B.sort(key=lambda t: -t[0])
    dp=[[0]*(N+1) for _ in range(N+1)]
    ans=0
    for i in range(N):
        for x in range(i+1):
            y=i-x
            dp[x+1][y]=max(dp[x+1][y],dp[x][y]+B[i][0]*abs(B[i][1]-x))
            dp[x][y+1]=max(dp[x][y+1],dp[x][y]+B[i][0]*abs(N-1-y-B[i][1]))
            ans=max(ans,dp[x+1][y],dp[x][y+1])
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 100652
#include <cstdio>
#include <map>
using namespace std;

int main() {  
  int n, m; scanf("%d %d", &n, &m);
  
  multimap<int, int> demands;
  for (int i = 0; i < m; i++) {
    int a, b; scanf("%d %d", &a, &b);
    demands.emplace(b, a);
  }
  
  int ans = 0;
  for (int i = 2; i <= n; i++) {
    if (!demands.count(i)) continue;
    ans++;
    for (auto it = demands.begin(); it != demands.end(); it++) {
      if ((*it).second < i) demands.erase(it);
    }
  }
    
  printf("%d\n", ans);
}

Measured memory_bytes: 6912
s = gets.chomp.to_s
ans = 0
previous_a_count = 0

# s を先頭から検索し "ABC" が含まれる限り、繰り返す
while s.index("ABC") do
  # 前半の文字列を "....A" とする
  former_s = s[0..s.index("ABC")]
  # 後半の文字列を "BC...." とする
  latter_s = s[s.index("ABC") + 1 ..s.length]
  a_count = 0
  bc_count = 0

  # 前半の文字列の末尾に "A" が何回連続で出現するか調べる
  while former_s.end_with?("A") do
    # 出現した "A" は削除する
    former_s.slice!(former_s.length - 1)
    a_count += 1
  end

  # 後半の文字列の先頭に "BC" が何回連続で出現するか調べる
  while latter_s.start_with?("BC") do
    # 出現した "BC" は削除する
    latter_s.slice!(0, 2)
    bc_count += 1
  end

  # s が "ABC" "AAAABC" などで始まる場合は、 previous_a_count を a_count に加算する
  if a_count - s.index("ABC") == 1
    a_count += previous_a_count
  end

  # "A" の出現回数と "BC" の出現回数をかけ合わせ、 ans に加算する
  # （例えば "AAABCBC" なら、"BCBCAAA" になるまで6回の操作が必要である）
  ans += a_count * bc_count

  # 次回のループには、後半の文字列を用いる
  # （前半の文字列には "ABC" は含まれていないため）
  s  = latter_s
  # a_count を 前回の a_count として格納しておく
  previous_a_count = a_count
end

puts ans

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

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b)) {
		cout << 'A' << endl;
	}
	else {
		cout << 'B' << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*
	##############################
	## Author: Pratyush Gaurav ###
	## College: NIT ROURKELA #####
	##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long/*--------------------*/lli;
typedef long double/*------------------*/ld;
typedef pair<lli, lli >/*--------------*/plli;
typedef vector<lli>/*------------------*/vlli;
typedef vector<plli >/*----------------*/vplli;

#define rep(i,a)/*---------------------*/for(i = 0 ; i < a ; i++)
#define repr(i,a)/*--------------------*/for(i = a ; i >= 0 ; i--)
#define REP(i,a,b)/*-------------------*/for(i = a ; i <= b ; i++)
#define REPR(i,a,b)/*------------------*/for(i = a ; i >= b ; i--)

#define scan(N)/*----------------------*/scanf("%lld",&N)
#define print(N)/*---------------------*/printf("%lld",N)
#define scan2(N1,N2)/*-----------------*/scanf("%lld %lld",&N1,&N2)
#define print2(N1,N2)/*----------------*/printf("%lld %lld",N1,N2)
#define scan3(N1,N2,N3)/*--------------*/scanf("%lld %lld %lld",&N1,&N2,&N3)
#define print3(N1,N2,N3)/*-------------*/printf("%lld %lld %lld",N1,N2,N3)

#define mem(a,b)/*---------------------*/memset(a,b,sizeof(a))
#define opt/*--------------------------*/ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b)/*--------------------*/__gcd(a, b)
#define lcm(a, b)/*--------------------*/((a)*((b)/gcd(a,b)))
#define sqr(x)/*-----------------------*/(x)*(x)
#define all(a)/*-----------------------*/a.begin(),a.end()
#define makepair/*---------------------*/make_pair

#define endl/*-------------------------*/'\n'
#define inf/*--------------------------*/(lli)2000000000000
#define MOD/*--------------------------*/(lli)1000000007
#define MAXN/*-------------------------*/100005

template<class T> bool is_prime(T n)
{
	if((n%2 == 0 and n > 2) or n < 2 )
		return false;
	for(T i = 3; i*i <= n ; i += 2)
	{
		if( n % i == 0)
			return false;
	}
	return true;
}
lli power(lli a,lli b)
{
    lli value;
    if(!b)
    	return 1;
    else if(b%2==0)
    {
        value = power(a,b/2)%MOD;
        return (value * value)%MOD;
    }
    else
    {
        value = power(a,b/2)%MOD;
        return ((a*value)%MOD*(value))%MOD;
    }
}
struct train
{
    lli c,f,s;
};

int main()
{
	opt;
    lli i,n,j;
    cin >> n;
    train t[n];
    for(i = 1 ;i <= n-1 ; i++)
    {
        cin >> t[i].c >> t[i].s >> t[i].f;
    }

    lli ans = 0,ti = 0;
    for(i = 1 ;i <= n-1 ; i++)
    {
        ans = 0;
        for(j = i ;j <= n-1 ; j++)
        {
            if(ans <= t[j].s)
            {
                ans += t[j].s - ans;
            }
            else if(ans % t[j].f)
            {
                ans += t[j].f - (ans % t[j].f);
            }

            ans += t[j].c;
        }
        cout << ans << endl;
    }
    cout << 0 ;
	return 0;
}










Measured memory_bytes: 256
#include <cstdio>

using namespace std;

const int maxn = 1e5+5;
int n;
//f[i] = min(f[i-1]+abs(h[i],h[i-1]),f[i-2] + abs(h[i],h[i-2]));
int h[maxn],f[maxn];

int abs(int x,int y) {
	if (x - y < 0) return y - x;
	return x - y;
}

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

int main() {
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) {
		scanf("%d",&h[i]);
	}
	f[0] = f[1] = 0;
	f[2] = abs(h[1],h[2]);
	for (int i = 3; i <= n; i++) {
		f[i] = min(f[i-1]+abs(h[i],h[i-1]),f[i-2] + abs(h[i],h[i-2]));
	}
	printf ("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 896
def main():
    N = int(input())
    T = list(map(int, input().split()))
    V = list(map(int, input().split()))
    T = [t * 2 for t in T]
    V = [v * 2 for v in V]
    Tall = sum(T)
    R = [0] * (Tall + 1)
    j = N - 1
    tc, vc, vn = T[-1], V[-1], V[-1]
    R[-1] = 0
    for i in reversed(range(Tall)):
        tc -= 1
        if tc == 0:
            j -= 1
            tc, vn = T[j], V[j]
        R[i] = min(R[i + 1] + 1, vc, vn)
        vc = vn
    v = 0
    d = 0.0
    j = 0
    tc, vc, vn = T[j], V[j], V[j]
    T.append(0)
    V.append(0)
    for i in range(1, Tall + 1):
        tc -= 1
        if tc == 0:
            j += 1
            tc, vn = T[j], V[j]
        vnn = min(v + 1, R[i], vc, vn)
        d += (v + vnn) / 2
        vc = vn
        v = vnn
    print(d / 4)

main()


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

using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define all(v) v.begin(),v.end()
#define ve vector
#define vi vector<int>
#define vi2 vector<vi>
#define vl vector<long long>
#define vl2 vector<vl>

template <class T> T maxAny(T a, T b){
    if(a > b) return a;
    else return b;
}

template <class T> T minAny(T a, T b){
    if(a > b) return b;
    else return a;
}

int main(){
    long long n, d, ans = 0;
    cin >> n >> d;
    long long x[n],y[n];
    rep(i,n) cin >> x[i] >> y[i];
    rep(i,n){
        long double dist;
        dist = sqrt(x[i]*x[i] + y[i]*y[i]);
        if(dist <= d) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6800
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int[] A = IntStream.range(0,N).map(i -> scan.nextInt()).toArray();

        int[] num = new int[N+1];
        int[] line = new int[N+1];
        Arrays.fill(num,0);
        Arrays.fill(line,0);
        for(int i=0;i<N;++i)num[A[i]]++;
        for(int i=1;i<=N;++i){
            for(int j=0;j<num[i];j++){
                if(i>j)line[i-j]++;
            }
        }

        int gap=0;
        for(int i=1;i<=N;++i)if(line[i]<=0)++gap;

        while(M-->0){
            int x = scan.nextInt() -1;
            int y = scan.nextInt();

            int a = A[x];//元々書かれてた数字
            A[x] = y;
            --num[a];
            if(a-num[a]>0){
                --line[a-num[a]];
                if(line[a-num[a]] == 0)++gap;
            }
            ++num[y];
            if(y-num[y] +1 >0){
                if(line[y-num[y]+1] == 0)--gap;
                ++line[y-num[y] +1];
            }
            System.out.println(gap);
//            for(int i=1;i<=N;++i)System.out.print(line[i] + " ");
//            System.out.println();
        }
    }
}

Measured memory_bytes: 156756
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        v: [[i64; 2]; n]
    }
    let odd = (v[0][0] + v[0][1]).abs() % 2;
    for i in 1..n {
        let x = v[i][0];
        let y = v[i][1];
        if (x + y).abs() % 2 != odd {
            println!("-1");
            return;
        }
    }
    let m = 31;
    if odd == 0 {
        println!("{}", m + 1);
        print!("1 ");
    } else {
        println!("{}", m);
    }
    for i in 0..m-1 {
        print!("{} ", 1 << i);
    }
    println!("{}", 1 << m-1);
    for i in 0..n {
        let mut x = v[i][0];
        let y = v[i][1];
        let mut moves: Vec<char> = Vec::new();
        if odd == 0 {
            x -= 1;
            moves.push('R');
        }
        let u = x + y;
        let v = x - y;
        let mut tu = ((1 << 31) - 1 - u) >> 1;
        let mut su = vec![false; 31];
        for j in 0..31 {
            su[j] = tu & 1 == 0;
            tu >>= 1;
        }
        let mut tv = ((1 << 31) - 1 - v) >> 1;
        let mut sv = vec![false; 31];
        for j in 0..31 {
            sv[j] = tv % 2 == 0;
            tv >>= 1;
        }
        for j in 0..31 {
            if su[j] {
                if sv[j] {
                    moves.push('R');
                } else {
                    moves.push('U');
                }
            } else if sv[j] {
                moves.push('D');
            } else {
                moves.push('L');
            }
        }
        println!("{}",moves.into_iter().collect::<String>());
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
vector<int> v[20010];
int main(){
	int n,x,y,l,r,z,i,j,w,a=1145141919;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x>>y;x+=10000,y+=10000;
		w=sqrt(a);
		for(j=max(0,x-w);j<=min(20005,x+w);j++){
			l=0,r=v[j].size();
			while(l<r){
				z=(r+l)/2;
				a=min(a,(x-j)*(x-j)+(y-v[j][z])*(y-v[j][z]));
				if(v[j][z]<y)l=z+1;
				else r=z;
			}
		}
		v[x].push_back(y);
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 7128
#include <stdio.h>

int main(void) {
  int N;
  int A;
  int B;
  
  scanf("%d", &N);
  scanf("%d", &A);
  scanf("%d", &B);

  

  if(N*A < B) {
      printf("%d\n", N*A);
  } else if(N*A > B) {
      printf("%d\n", B);
  } else {
      printf("%d\n", B);
  }

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n, max=0, c=0;
    cin >> n;
    vector<int> h(n);
    vector<int> v(n, 0);

    for (int i = 0;i < n; ++i) {
        cin >> h[i];
        if (h[i] >= max) {
            max = h[i];
            c++;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int H, W, i,j;

	while(1)
	{
		scanf("%d%d", &H, &W);
		if ((H == 0) && (W == 0)) break;

		for (j = 0;j < H;j++)
		{
			for (i = 0;i < W;i++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
		return 0;
	
}


Measured memory_bytes: 572
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

size_t isort(vector<int> &A, size_t g) {
    size_t count_=0;
    for (size_t i=g; i<A.size(); ++i) {
        int v=A[i], j;
        for (j=i-g; j>=0&&v<A[j]; j-=g) {
            A[j+g] = A[j];
            ++count_;
        }
        A[j+g] = v;
    }
    return count_;
}

size_t shsort(vector<int> &A) {
    /* Shell sort */
    size_t count_=0;
    size_t m=A.size();

    vector<size_t> g; g.push_back(1);
    for (size_t h=4; h<=m&&g.size()<100; ++(h*=3))
        g.push_back(h);

    reverse(g.begin(), g.end());

    printf("%zu\n", g.size());
    for (size_t i=0; i<g.size(); ++i) {
        printf("%zu%c", g[i], i<g.size()-1? ' ':'\n');
        count_ += isort(A, g[i]);
    }

    return count_;
}

int main() {
    size_t N;
    scanf("%zu", &N);

    vector<int> A(N);
    for (size_t i=0; i<N; ++i)
        scanf("%d", &A[i]);

    size_t t=shsort(A);

    printf("%zu\n", t);
    for (size_t i=0; i<N; ++i)
        printf("%d\n", A[i]);

    return 0;
}

Measured memory_bytes: 6320
#include<bits/stdc++.h>
using namespace std;
typedef long long llint;
const llint MOD = 998244353;
int main() {
    int N, K, r = 0, a;
    cin >> N >> K;
    for(int i = 0; i < N; i++) {
        cin >> a;
        if(a >= K)
            r++;
    }
    cout << r;
} 

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

void solve(int N, vector<int> b){
    vector<int> ans;
    for(int i = 0; i < N; ++i){
        int val = 0;
        int pos = 0;
        for(int j = 0; j < b.size(); ++j){
            if(b[j] == j + 1){
                val = b[j];
                pos = j;
            }
        }
        if(val > 0){
            ans.push_back(val);
            b.erase(b.begin() + pos);
        }else break;
    }
    if(ans.size() != N) cout << -1 << endl;
    else{
        reverse(ans.begin(), ans.end());
        for(int i = 0; i < N; ++i) cout << ans[i] << endl;
    }
}

int main(){
    int N;
    cin >> N;
    vector<int> b(N, 0);
    for(int i = 0; i < N; ++i) cin >> b[i];
    solve(N, move(b));
    return 0;
}


Measured memory_bytes: 256
use std::io::{BufRead, Write};

fn main() {
    let stdin = std::io::stdin();
    let stdout = std::io::stdout();
    let mut reader = std::io::BufReader::new(stdin.lock());
    let mut writer = std::io::BufWriter::new(stdout.lock());

    let s: String = {
        let mut buf = String::new();
        reader.read_line(&mut buf).unwrap();
        buf.trim_end().to_owned()
    };

    let ans = &s[0..3];
    writeln!(writer, "{}", ans).unwrap();
}

Measured memory_bytes: 2152
#include<stdio.h>
int main(){
 int H[3000],W[3000];
 int i,j,k,m;

 for(i=0;i<3000;i++){
  scanf("%d %d\n",&H[i],&W[i]);
  
  if(H[i]==0 && W[i]==0){
   j=i;
   break;
  }
  }

 for(i=0;i<=j-1;i++){

  for(k=0;k<H[i];k++){
 
   for(m=0;m<W[i]-1;m++){
    printf("#");
   }
   printf("#\n");

  }
  
 printf("\n");

 }

return 0;
}

  

Measured memory_bytes: 604
"""
演算子は要素とセットでモノイドを形成するようなものでなければならない。
すなわち、結合律が成り立ち単位元が存在する必要がある。

equalityはsetを高速化するために使う。めんどい場合はNoneにしてもOK
"""
class SegmentTree:

    @classmethod
    def all_identity(cls, operator, equality, identity, size):
        return cls(operator, equality, identity, [identity]*(2 << (size-1).bit_length()))

    @classmethod
    def from_initial_data(cls, operator, equality, identity, data):
        size = 1 << (len(data)-1).bit_length()
        temp = [identity]*(2*size)
        temp[size:size+len(data)] = data
        data = temp

        for i in reversed(range(size)):
            data[i] = operator(data[2*i],data[2*i+1])
        return cls(operator, equality, identity, data)

    # これ使わずファクトリーメソッド使いましょうね
    def __init__(self, operator, equality, identity, data):
        if equality is None:
            equality = lambda a,b: False
        self.op = operator
        self.eq = equality
        self.id = identity
        self.data = data
        self.size = len(data)//2

    def _interval(self, a, b):
        a += self.size
        b += self.size
        ra = self.id
        rb = self.id

        data = self.data
        op = self.op
        while a < b:
            if a & 1:
                ra = op(ra,data[a])
                a += 1
            if b & 1:
                b -= 1
                rb = op(data[b],rb)
            a >>= 1
            b >>= 1
        return op(ra,rb)

    def __getitem__(self, i):
        if isinstance(i, slice):
            return self._interval(
                                    0 if i.start is None else i.start,
                                    self.size if i.stop is None else i.stop)
        elif isinstance(i, int):
            return self.data[i+self.size]

    def __setitem__(self, i, v):
        i += self.size
        data = self.data
        op = self.op
        eq = self.eq
        while i and not eq(data[i],v):
            data[i] = v
            v = op(data[i^1],v) if i & 1 else op(v,data[i^1])
            i >>= 1

    def __iter__(self):
        return self.data[self.size:]

from operator import eq

def solve():

    N = int(input())

    A = list(map(int,input().split()))
    B = list(map(int,input().split()))

    max_finder = SegmentTree.from_initial_data(max, eq, (0,0), [(0 if A[i] == v else v,i) for i,v in enumerate(B)])
    cnt = 0
    v,i = max_finder[:]

    while v != 0:
        delta = B[i-1] + B[i-N+1]
        n = (B[i]-A[i])//delta
        if n <= 0:
            print(-1)
            return
        else:
            B[i] -= n*delta
            max_finder[i] = (0 if B[i] == A[i] else B[i], i)
        cnt += n
        v,i = max_finder[:]

    print(cnt)


solve()



Measured memory_bytes: 123812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    string s; cin>>s;
    for(int i=0;i<s.size();i++){
        if(i%2==1){
            if(s[i]=='R'){
                cout<<"No"<<endl;
                return 0;
            }
        }else{
            if(s[i]=='L'){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    
}


Measured memory_bytes: 256