akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  vector<int> v(3);
  for (int i=0; i<3; i++) cin>>v[i];
  sort(v.begin(), v.end());
  int ans = (10*v[2]+v[1]+v[0]);
  cout<<ans<<endl;
  

  return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define fo(i, n) for(int i = 1; i <= n; ++i)
#define rep(i, a, b) for(int (i) = (a); (i) < (b); ++(i))

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

const int N = 200200;
const int mod = 1e9 + 7;
const ll INF = 1e18;
ll n,a[N],b[N],c[N],ma,mb;
ll dp[1000][1000];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	cin>>ma>>mb;
	fo(i,n)cin>>a[i]>>b[i]>>c[i];
	for(int i=0;i<=400;++i)
		for(int j=0;j<=400;++j)
			dp[i][j]=1e9;
	dp[0][0]=0;
	fo(i,n)
		for(int sa=400;sa>=0;--sa)
			for(int sb=400;sb>=0;--sb)
				if(sa-a[i]>=0&&sb-b[i]>=0)
					dp[sa][sb]=min(dp[sa][sb],dp[sa-a[i]][sb-b[i]]+c[i]);
	ll ans=1e9;
	for(int i=1;i<=400;++i)
		for(int j=1;j<=400;++j)
		{
			int x=i,y=j;
			int g=__gcd(x,y);
			x/=g,y/=g;
			if(x==ma&&y==mb)
				ans=min(ans,dp[i][j]);
		}
	if(ans<=5000)
		cout<<ans;
	else
		cout<<-1;
	return 0;	
}

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

int dp[50010];

const int INF=1<<29;

int main(){
  int n,m,i,j;
  cin >> n >> m;
  vector<int> a(n);
  for(i=0;i<m;++i){
    cin >> a[i];
  }
  for(i=0;i<=n;++i){
    dp[i]=INF;
  }
  dp[0]=0;
  for(i=0;i<m;++i){
    for(j=0;j+a[i]<=n;++j){
      dp[j+a[i]]=min(dp[j+a[i]],dp[j]+1);
    }
  }
  cout << dp[n] <<endl;
  return 0;

}



Measured memory_bytes: 3284
N = int(input())
T, A = map(int, input().split())
Hn = list(map(int, input().split()))

An = [T - 0.006*i for i in Hn]

tp = [10000000]*(N+1)
tpa = N
for i in range(N):
  tp[i] = abs(A - An[i])
  tpa = i if tp[i] < tp[tpa] else tpa

print(tpa+1)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <iomanip>
using ll = long long;
using namespace std;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r) { return l.second < r.second; }
bool greaterPair(const ipair& l, const ipair& r) { return l.second > r.second; }

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define irep(i, n) for (int i = 0; i <= (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rirep(i, n) for (int i = n; i >= 0; --i)
int factorical(int n) {
	int sum = 1;
	for (int i = 1; i <= n; ++i)
	{
		sum *= i;
	}
	return sum;
}

vector<int> divisors(int n) {
	vector<int> res;
	for (int i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}
vector<ll> divisors_ll(ll n) {
	vector<ll> res;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}


void printVector(const vector<int>& vec) {
	for (int value : vec) {
		cout << value << " ";
	}
	cout << endl;
}

bool pal(string s) {
	int n = s.length() / 2;
			rep(i, n) {
			if (s[i] != s[s.length() - 1 - i]) return false;
		}
			return true;
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n-1);
	rep(i, n-1) {
		cin >> a[i];
	};
	vector <int> ans(n);
	rep(i, n-1) {
		ans[a[i]-1] += 1;
	}
	for (auto a : ans) {
		std::cout << a << endl << endl;
	}
	return 0;
}




Measured memory_bytes: 4760
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n;
	int max=0;
	int ans=1,cnt=0;
	int tmp;
	cin>>n;
	for(int i=n;i>=1;i--)
	{
		tmp=i;
		cnt=0;
		while(1)
		{
			if(tmp%2==0) cnt++;
			else break;
			tmp=tmp/2;
		} 
		if(cnt>max)
		{
			max=cnt;
			ans=i;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
# 2019/02/06
# AtCoder Beginner Contest110 - B

# Input
n, m, x, y = map(int,input().split())
x_list = list(map(int,input().split()))
y_list = list(map(int,input().split()))

x_max = x
y_min = y

# Search max
for i in range(n):
    if x_list[i] > x_max:
        x_max = x_list[i]

# Search min
for i in range(m):
    if y_list[i] < y_min:
        y_min = y_list[i]

if x_max < y_min:
    ans = "No War"
else:
    ans = "War"

# Output
print(ans)

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

# input
S = input()

# solve
is_diffrent = True
for i in range(len(S)):
    for j in range(i + 1, len(S)):
        if S[i] == S[j]:
            is_diffrent = False

# output
print('yes' if is_diffrent else 'no')


Measured memory_bytes: 2940
import math
a, b, h, m = map(int, input().split())
# 時針
dig_h = 0
if (60 * h + m) / 2 <= 90:
    dig_h = 90 - (60 * h + m) / 2
else:
    dig_h = 450 - (60 * h + m) / 2
rad_h = math.radians(dig_h)
A = [a * math.cos(rad_h), a * math.sin(rad_h)]

# 分針
dig_m = 0
if (6 * m) <= 90:
    dig_m = 90 - 6 * m
else:
    dig_m = 450 - 6 * m
rad_m = math.radians(dig_m)
B = [b * math.cos(rad_m), b * math.sin(rad_m)]

# 2点間の距離
ans = math.sqrt((A[0] - B[0]) ** 2 + (A[1] - B[1]) ** 2)
print(ans)

Measured memory_bytes: 9616
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 3e3 + 5;
const int mod = 1e9 + 7;
int n;
double ans, p[N], dp[N][N];
int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) scanf("%lf", p + i);
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= i; ++j) {
			dp[i][j] = dp[i - 1][j] * (1 - p[i]);
			if (j) dp[i][j] += dp[i - 1][j - 1] * p[i];
		}
	}
	for (int i = (n + 1) / 2; i <= n; ++i) ans += dp[n][i];
	printf("%.10f\n", ans);
}


Measured memory_bytes: 68992
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int a,b,c;
  cin >> a >> b >> c;
  
  if(b-a == c-b) cout << "YES" << endl;
  else           cout << "NO"  << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int judge(int num){
  int j = 3;
  if (num==2) {
    return 1;
  } else if (num<2 || num%2==0) {
    return 0;
  } else {
    while (j<=sqrt(num)) {
      if (num%j==0) {
        return 0;
      }
      j=j+2;
    }
    return 1;
  }
 }

int main(){
  int n, num, i;
  int count = 0;
  scanf("%d", &n);

  for (i=0; i<n; i++) {
    scanf("%d", &num);
    count=count+judge(num);
  }

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

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

int main(){
    int x,y;
    while(true){
        cin >> x >> y;
        if(x == 0 && y == 0){
            break;
        }
        cout << (x < y ? x : y) << " " << (x > y ? x : y) << endl;
    }
    return 0;
}

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

int main(){

  int n;
  int miremiam = 196471;
  int big = 200;
  int small = 195;
  int ans = 0;
  
  cin >> n;

  int year, month, day;

  for(int i = 0; i < n; i++){
    cin >> year >> month >> day;
    for(int j = 1; j < year; j++){
      if(j % 3 == 0) ans += big;
      else ans += small;
      //  cout << ans << endl;
      }
    for(int s = 1; s < month; s++){
      if(year % 3 == 0) ans += 20;
      else if(s % 2 == 0) ans += 19;
      else ans += 20;
    }
    ans += day;
    // cout << ans << endl;
    cout << miremiam - ans << endl;
    ans = 0;

  }
  


  return 0;
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
  FAST();

  ll a, b, k;
  cin >> a >> b >> k;

  if(a >= k && a != 0)
    a -= k;
  else{
    ll x = k - a;
    a = 0;
    if(b >= x)
        b -= x;
    else
        b = 0;
  }
  cout << a << " " << b << endl;


  return 0;
}


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

int main(){
  char a, b;
  int x, y;
  cin >> a >> b;
  if (a == 'H') x = 0;
  if (a == 'D') x = 1;
  if (b == 'H') y = 0;
  if (b == 'D') y = 1;
  if (x ^ y == 0) {
    cout << "H" << endl;
  } else {
    cout << "D" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt();
			int a = scanner.nextInt(), b = scanner.nextInt();
			System.out.println(((0 == (a % k)) || ((a / k) != (b / k))) ? "OK" : "NG");
		}
	}
}


Measured memory_bytes: 35660
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s, t; cin >> s >> t;
	if (s == t.substr(0, s.size())) {
		cout << "Yes" << "\n";
	}
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl

ll n,x;
map<ll,ll>m;

int main() {
slld(n);
bool y=1;
for(int i=1;i<=n;i++)
{
	slld(x);
	m[x]++;
}
ll q;
slld(q);
for(int i=1;i<=q;i++)
{
	slld(x);
	if(!m[x])y=0;
	m[x]--;
}
if(y)
	pss("YES\n");
else
	pss("NO\n");
    return 0;
           }

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

int main()
{
    long long n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    if (a>b)
    {
        printf("0");
    }
    else if(n==1)
    {
        printf(a==b?"1":"0");
    }
    else printf("%lld",(n-2)*(b-a)+1);
}


Measured memory_bytes: 256
import sys
import bisect


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    X = list(map(int, input().split()))
    S = []
    ans = 10 ** 9 + 7

    start = bisect.bisect(X, 0)

    for i in range(min(start+1,K+1)):
        temp = 0
        if N - start < K-i:  #右にある個数が取るべき個数を超えたときはスキップ
            continue

        if i ==0:
            ans = min(X[start+K-1],ans)
            continue

        if i ==K:
            ans =min(-X[start-K],ans)
            continue
        # 左から
        temp += -X[start - i] * 2
        temp += X[start + K - i-1]
        ans = min(temp, ans)

        # 右から

        temp = X[start + K - i-1] * 2
        temp += -X[start - i]
        ans = min(temp, ans)





    print(ans)




if __name__ == "__main__":
    main()


Measured memory_bytes: 85408
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int A=scan.nextInt(),B=scan.nextInt(),C=scan.nextInt();
        if((A!=5&&A!=7)||(B!=5&&B!=7)||(C!=5&&C!=7)){
            System.out.println("NO");
        }else if(A+B+C!=17){
             System.out.println("NO");
        }else{
            System.out.println("YES");
        }
    }
}


Measured memory_bytes: 35608
//Strawberry Cakes

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int h,w,k;cin>>h>>w>>k;
    vecrep(h,m,string);
    vector<vector<int>>a(h,vector<int>(w,-1));
    int y=0,n=1;
    rep(i,0,h){
        int c = 0,x = 0;
        vector<int>t;
        rep(j,0,w){
            if(m[i][j]=='#'){
                c++;
                t.pb(j);
            }
        }
        t.pb(500);
        if(c==0&&k==0){
            a[i]=a[i-1];
            y=i+1;
        }else if(c==1){
            rep(j,y,i+1){
                rep(r,0,w)a[j][r]=n;
            }
            k--;n++;
            y=i+1;
        }else if(c>1){
            rep(l,1,c+1){
                rep(r,x,min(t[l],w)){
                    rep(j,y,i+1){
                        a[j][r]=n;
                    }
                }
                n++;k--;
                x=t[l];
            }

            y=i+1;
        }
    }
    rep(i,0,h){
        rep(j,0,w){
            cout<<a[i][j]<<spa;
        }
        cout<<nnn;
    }
    return 0;
}

Measured memory_bytes: 4468
fun main() {
    val (n, k) = readLine()?.split(" ")?.map(String::toLong) ?: return
    val nn = n + 1
    if (nn <= k) {
        println(1L)
        return
    }
    val m = 1000000007L
    val values = 0.until(nn).map {
        it
    }
    val c = nn - k
    val maxValue = values.sum()
    var minSum = maxValue
    var maxSum = maxValue
    var count = ((maxSum - minSum) + 1) % m
    repeat(c.toInt()) {
        minSum -= values[values.size - it - 1]
        maxSum -= values[it]
        count = (count + (maxSum - minSum) + 1) % m
    }
    println(count)
}


Measured memory_bytes: 44848
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }


main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector <int> a(n);
    for (auto &i : a) cin >> i;
    int ans = 0, A, b;
    vector  <vector <int> > edge(n);
    for (int i = 0; i < m; i++) {
        cin >> A >> b;
        --A, --b;
        edge[A].pb(b);
        edge[b].pb(A);
    }
    for (int i = 0; i < n; i++) {
        bool ok = true;
        for (auto &j : edge[i]) {
            if (a[i] <= a[j]) {
                ok = false;
                break;
            }
        }
        if (ok) ++ans;
    }
    cout << ans << '\n';
}


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

using ll=long long;
using VI=vector<ll>;
using VVI=vector<VI>;

class UnionFind{
public:
	vector<int> par;// par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2
	UnionFind(int N):par(N) {
		for (int i = 0; i < N; ++i) par[i] = i;
	}
	int root(int x){// データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if(par[x]==x)return x;
		else return par[x]=root(par[x]);
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};

	int unite(int x,int y){
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return 0; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		return 0;
	}
};


int main(){
	int N,M,K;
	int result=0;
	cin>>N>>M>>K;
	UnionFind tree(N);
	VVI friends(N);
	VVI blocks(N);
	VI group(N);
	int a,b,c,d;
	rep(i,M){
		cin>>a>>b;
		a--;b--;
		tree.unite(a,b);
		friends[a].push_back(b);
		friends[b].push_back(a);
	}
	rep(i,K){
		cin>>c>>d;
		c--;d--;
		blocks[c].push_back(d);
		blocks[d].push_back(c);
	}
	rep(i,N) group[tree.root(i)]++; //unite されて繋がっている人の数???

	rep(i,N){
		result=group[tree.root(i)]-1; // unite されて繋がっている人の数 - 自分
		rep(j,friends[i].size()) if(tree.root(i)==tree.root(friends[i][j])) result--; //すでに友達のになっている数引いていく
		rep(j,blocks[i].size()) if(tree.root(i)==tree.root(blocks[i][j])) result--; //Blockの数引いてく
		cout<<result;
		if(i!=N-1) cout<<" ";
	}
	return 0;
}


Measured memory_bytes: 14452
import sys
from fractions import gcd
from functools import reduce
from itertools import combinations

import numpy as np

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    A, B = il()
    N = ii(str)
    a = []
    for i in range(A):
        a.append(N[i].lower() if i == B - 1 else N[i])
    return "".join(a)


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 23016
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> a;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------

  if(a>999) anss = "ABD";
  else anss = "ABC";

  cout << anss << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
        int n,i;
        int ary[1000];
        scanf("%d",&n);
        for(i=0;i<n;i++)
                scanf("%d",&ary[i]);

        printf("%d",ary[n-1]);
        for(i=1;i<n;i++)
                printf(" %d",ary[n-(i+1)]);
        puts("");
        return 0;
}


Measured memory_bytes: 2092
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int a, b, c; cin >> a >> b >> c;
	if (a + b == c || a + c == b || b + c == a)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
const ll mod = 1000000007;


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

  for(int i=1;i<10;i++){
    if(n%i==0){
      if(n/i<10){cout<<"Yes"<<endl;return 0;}

    }
  }
  cout<<"No"<<endl;
  return 0;
}


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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")   */


//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 5e5 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 2e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

int t[26][N];

void inc (int i, int j, int del) {
    for (; j < N; j |= (j + 1)) t[i][j] += del;
}

int sum (int i, int j) {
    int ans = 0;
    for (; j >= 0; j = (j & (j + 1)) - 1) ans += t[i][j];
    return ans;
}

int summ (int i, int l, int r) {
    return sum(i, r) - sum(i, l - 1);
}

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        inc(s[i] - 'a', i, 1);
    }
    int q;
    cin >> q;
    while (q--) {
        int type;
        cin >> type;
        if (type == 1) {
            int x;
            char c;
            cin >> x >> c;
            x--;
            inc(s[x] - 'a', x, -1);
            s[x] = c;
            inc(s[x] - 'a', x, 1);
        }
        else {
            int l, r, ans = 0;
            cin >> l >> r;
            l--, r--;
            for (int i = 0; i < 26; i++) {
                int o = summ(i, l, r);
                if (o) ans++;
            }
            cout << ans << "\n";
        }
    }
}


Measured memory_bytes: 102556
#include<bits/stdc++.h>
#define rep(i,b) for(int i=1;i<=b;i++)
#define drep(i,b) for(int i=b;i>=1;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define int long long
#define endl '\n'
using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
int n,m,k,t,x,y,z;
//pr
//
#define mid (l+r)/2
#define ls i<<1
#define rs i<<1|1
//vec
//alg

int a[6000],az;

void solve(int sum=0) {
    cin>>n>>k;
    map<int,int> mp;
    rep(i,k) {
        cin>>x;
        rep(j,x) {
            cin>>y;
            mp[y]=1;
        }
    }
    cout<<n-mp.size()<<endl;
}

#undef int
int main() {
    ios::sync_with_stdio(false);
    //int T;cin>>T;
    //while(T--)
        solve();
}


Measured memory_bytes: 3688
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

constexpr long long INF = 1LL << 50;

int main() {

    int N, M, R;
    cin >> N >> M >> R;

    vector<int> r(R);
    for (int i = 0; i < R; i++) cin >> r[i], r[i]--;

    vector<vector<long long>> D(N, vector<long long>(N, INF));
    for (int i = 0; i < N; i++) D[i][i] = 0;

    for (int i = 0; i < M; i++) {
        long long a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        D[a][b] = D[b][a] = c;
    }

    for (int k = 0; k < N; k++) for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) D[i][j] = min(D[i][j], D[i][k] + D[k][j]);

    long long ans = LONG_LONG_MAX;
    sort(r.begin(), r.end());

    do {
        long long sum = 0;
        for (int i = 0; i < R - 1; i++) sum += D[r[i]][r[i + 1]];
        ans = min(sum, ans);
    } while (next_permutation(r.begin(), r.end()));

    cout << ans << endl;

    return 0;
}











































































Measured memory_bytes: 512
import scala.io.StdIn

object Main{
  def main(args: Array[String]){
    val line = StdIn.readLine().split(" ").toList.map(_.toInt)
    println(gcd(line.head, line.last))
  }

  def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
}

Measured memory_bytes: 43500
#include <iostream>
#include <map>
using namespace std;
//see answer
int main() {
	int N, M;
	cin >> N >> M;
	map<int, long long> Nums;
	int now = 0;
	Nums[0]++;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		now = (now + A % M) % M;
		Nums[now]++;
	}
	long long ans = 0;
	for (auto p : Nums) ans += p.second * (p.second - 1) / 2;
	cout << ans << endl;
}


Measured memory_bytes: 7568
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	string s;
	int k;
	cin >> k >> s;
	if (sz(s) <= k)
		cout << s << endl;
	else
		cout << s.substr(0, k) << "..." << endl;
}


Measured memory_bytes: 3656
typedef long long ll;
#include "bits/stdc++.h"
using namespace std;
int main() {
	int n,k;
	cin >> n >> k;
	vector<ll> h(n);
	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}

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


	ll ans = 1000000000;
	for (int i = 0; i + k - 1 < n; i++)
	{
		ans = min(ans,h[i + k - 1] - h[i]);
	}
	cout << ans << endl;

}

Measured memory_bytes: 1024
// D - Moving Piece
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int N, K; cin>>N>>K;
	vi P(N); rep(i, N) cin>>P[i], P[i]--;
	vi C(N); rep(i, N) cin>>C[i];

	ll INF = 1e18;
	ll score = -INF;
	rep(st, N){
		ll lap_sc = 0;
		int lap_cn = 0;
		int nx = st;
		while(true){
			lap_cn++;
			lap_sc += C[nx];
			if(st == (nx = P[nx])) break;
		}
		lap_sc = max(0LL, lap_sc);

		ll sum_sc = 0;
		for(int k_cn=1; k_cn<=K; k_cn++){
			sum_sc += C[nx];
			score = max(score, sum_sc + lap_sc * ((K - k_cn) / lap_cn));
			if(st == (nx = P[nx])) break;
		}
	}
	cout<< score <<endl;
}


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

int main(){
  bool bingo[3][3];
  int A[3][3];
  int N;
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++) bingo[i][j]=0;
  }
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++) cin >> A[i][j];
  }
  cin >> N;
  for(int i=0; i<N; i++){
    int b;
    cin >> b;
    for(int j=0; j<3; j++){
      for(int k=0; k<3; k++){
        if(b==A[j][k]) bingo[j][k]=1;
      }
    }
  }
  string ans = "No";
  if(bingo[0][0] && bingo[0][1] && bingo[0][2]) ans="Yes";
  if(bingo[1][0] && bingo[1][1] && bingo[1][2]) ans="Yes";
  if(bingo[2][0] && bingo[2][1] && bingo[2][2]) ans="Yes";
  if(bingo[0][0] && bingo[1][0] && bingo[2][0]) ans="Yes";
  if(bingo[0][1] && bingo[1][1] && bingo[2][1]) ans="Yes";
  if(bingo[0][2] && bingo[1][2] && bingo[2][2]) ans="Yes";
  if(bingo[0][0] && bingo[1][1] && bingo[2][2]) ans="Yes";
  if(bingo[2][0] && bingo[1][1] && bingo[0][2]) ans="Yes";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 100005
#define BT 1024*128*2
#define INF 100000000000005LL

using namespace std;
typedef long long int ll;

struct segtree
{
	ll seg[BT];
	int mum;
	
	void init(int n)
	{
		mum=1;
		while(mum<n) mum<<=1;
		for(int i=0;i<mum*2;i++) seg[i]=INF;
	}
	void add(int k,ll v)
	{
		k+=mum-1;
		seg[k]=min(seg[k],v);
		while(k>0)
		{
			k=(k-1)/2;
			seg[k]=min(seg[k*2+1],seg[k*2+2]);
		}
	}
	ll get(int a,int b,int k,int l,int r)
	{
		if(b<=l||r<=a) return INF;
		if(a<=l&&r<=b) return seg[k];
		else
		{
			ll vl=get(a,b,k*2+1,l,(l+r)/2);
			ll vr=get(a,b,k*2+2,(l+r)/2,r);
			return min(vl,vr);
		}
	}
	ll get(int a,int b)
	{
		return get(a,b,0,0,mum);
	}
};
segtree s1,s2;
int X[SIZE];
ll dp[SIZE];

int main()
{
	int n,E,T;
	scanf("%d %d %d",&n,&E,&T);
	for(int i=0;i<n;i++) scanf("%d",&X[i]);
	s1.init(n+2);
	s2.init(n+2);
	ll bef=E;
	for(int i=n-1;i>=0;i--)
	{
		s1.add(i,bef);
		s2.add(i,X[i]*2LL+bef);
		int pos=lower_bound(X,X+n,X[i]+T/2+1)-X-1;
		dp[i]=s1.get(i,pos+1)-X[i]+(ll) T;
		if(pos+1<n) dp[i]=min(dp[i],s2.get(pos+1,n)-(ll) X[i]*3LL);
		bef=X[i]+dp[i];
	}
	printf("%lld\n",bef);
	return 0;
}


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

int main(){
    int n;
    string s;
    cin>>n>>s;
    int count = 1;
    for(int i=0;i<n-1;i++){
        char now = s.at(i);
        char next = s.at(i+1);
        if(now == next){
            continue;
        }
        count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define pb(n) push_back(n);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
vector<int> vi;
vector<lln> vl;
vector<vector<pair<int, int> > > vii;
//vector<pii> vii;
vector<pll> vll;
//vii.clear();
//vii.resize(n + 1);


int arr[maxii];
int arr2[maxii];
bool check[maxii];
bool check2[1000][1000];
int n,m;
int x[]={1,-1,0,0};
int y[]={0,0,-1,1};
int x2[]={1,-1,0,0,1,-1,1,-1};
int y2[]={0,0,-1,1,1,-1,-1,1};
int bx[]={0,0,1,-1,-1,1,1,-1};
int by[]={1,-1,0,0,-1,-1,1,1};
int kx[] = {1,1,2,2,-1,-1,-2,-2};
int ky[] = {2,-2,1,-1,2,-2,1,-1};

bool isvisited(int xx,int yy)
{
    if(xx<1 || yy<1 || xx>n ||yy>m)
    {
        return false;
    }
    else if(check2[xx][yy]==true)
    {
        return false;
    }
    else return true;
}
int gcd(int a,int b)
{
    if(b==0){
      return a;
     }
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    int res=(a*b)/gcd(a,b);
    return res;
}
int po(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
        {
            res*=a;
            b--;
        }
        else
        {
            a*=a;
            b/=2;
        }
    }
    return res;
}

lln modMul(lln  a, lln b,lln mod){
    lln ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}
lln powerMod(lln a,lln b,lln mod){
	if(b==0)return 1LL%mod;
	lln x=powerMod( a,b/2,mod );
	x = ( x%mod * x%mod ) % mod;
	if( b%2==1 )x = ( x%mod * a%mod ) % mod;
	return x%mod;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int x;
    sc(x)
    if(x==1)
        cout<<0;

    else cout<<1;

}







Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;


long long modinv(long long a, long long m = 1e9+7) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

/* //約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}*/

int main() {
  ll N, mod = 1e9+7, ans=0, c, f=1;
  Vl cv;
  cin >> N;
  REP(i,N) {
    cin >> c;
    cv.push_back(c);
    }
  SORT(cv);
  REP(i,N) {
    ans = (cv[i]*(2+N-i-1)%mod+ans)%mod;
    f = f*4%mod;
  }
  ans = ans*f%mod*modinv(4)%mod;
  cout << ans << endl;
}

Measured memory_bytes: 2420
# -*- coding:utf-8 -*-
import sys
from collections import deque
input = sys.stdin.readline
s = list(input())
d = deque()
for i in s:
  if (i=='B')&(len(d)!=0):
    d.pop()
  elif (i=='B')&(len(d)==0):
    continue
  else:
    d.append(i)
print(''.join(list(d)))

Measured memory_bytes: 9340
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll L,R,d;
    cin>>L>>R>>d;
    ll ans=(R/d-L/d);
    if(L%d==0) ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
from fractions import gcd
from functools import reduce
N = int(input())
T = [int(input()) for _ in range(N)]


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


print(lcm_list(T))


Measured memory_bytes: 5076
#include<stdio.h>
#define N 10000

int main(){
  int n,nn[N],i,j,m=0,count=0;

  
  scanf("%d",&n);

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

  for(i=0;i<n;i++){
    for(j=2;j*j<=nn[i];j++){
      if(nn[i]%j==0){
	m++;
      }
    }
    if(m==0){
      count++;
    }
    m=0;
  }

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



Measured memory_bytes: 2068
import math
N = int(input())

k = 2
res = 0

ts = set()
kn = {N}
kn_1 = {N-1}
while k <= math.sqrt(N):
    if N % k == 0:
        nk = N//k
        while nk % k == 0:
            nk //= k

        if nk % k == 1:
            kn.add(k)
        if k % nk == 1:
            kn.add(nk)

        ts.add(k)
        ts.add(nk)

    if (N-1) % k == 0:
        kn_1.add(k)
        kn_1.add((N-1)//k)

    k+=1

kn_1 -= {1}
print(len(kn)+len(kn_1))

Measured memory_bytes: 3828
# https://atcoder.jp/contests/abc106/tasks/abc106_d
# どうやったら高速に区間[p,q]に完全に入っている区間の数を取得できるか？
# p,qを二次元座標として捉えると電車1本の線は二次元平面上の1点として表せる
# このときp,qの区間に完全に入っている電車の本数というのは、x軸、y軸の両方において[p,q]となる四角形内にある電車の本数
# queryに高速に答えるために二次元累積和を構築する
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret




# クラスで実装してみる
class cumsum2d:
    def __init__(self, ls: list):
        '''
        2次元のリストを受け取る
        '''
        import numpy as np
        self.ls = np.array(ls)
        H, W = self.ls.shape
        self.ls_accum = np.zeros((H + 1, W + 1))
        self.ls_accum[1:, 1:] = self.ls.cumsum(axis=0).cumsum(axis=1)

    def total(self, i1, j1, i2, j2):
        '''
        点(i1,j1),(i1,j2),(i2,j1),(i2,j2)の4点が成す四角の中の合計を取り出す
        ただし i1<=i2, j1<=j2
        ただし、i軸に関しては[i1,i2),j軸に関しては[j1,j2)の半開区間である
        '''
        return self.ls_accum[i2, j2] - self.ls_accum[i1, j2] \
            - self.ls_accum[i2, j1] + self.ls_accum[i1, j1]


N, M, Q = read_ints()
LR = read_tuple(M)
pq = read_tuple(Q)

# numpy使わずに再実装 #入れるときはpythonのほうが速いので
LR2d = [[0] * (N + 1) for _ in range(N + 1)]
for L, R in LR:
    LR2d[L][R] += 1

LR2d_accum = cumsum2d(LR2d)

# queryに答えていく
ans = []
for p, q in pq:
    ans.append(int(LR2d_accum.total(p, p, q + 1, q + 1)))

print(*ans, sep='\n')


Measured memory_bytes: 55160
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000009
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main() {
    fastio;
	long long int a,b,x,y,p,q,r,s;
	int flag=0,se=0,ko=0;
	cin>>a>>b>>x>>y;
	p = (y/__gcd(x,y))*x;
	if(a%x==0) flag=1;
	if(a%y==0) se=1;
	if(a%p==0) ko=1;
	q = b/x - a/x + flag;
	r = b/y - a/y +se;
	s = b/p - a/p +ko;
	cout<<b-a+1+s-q-r;
	return 0;
}

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

int main(){
    long N;
    cin >> N;
    long a0;
    cin >> a0;

    long count = 0;
    long ai;
    bool increase = false;
    bool decrease = false;
    for(long i = 1; i < N; i++){
        cin >> ai;
        if(ai == a0) continue;
        if(ai > a0){
            increase = true;
        }
        if (ai < a0){
            decrease = true;
        }
        if(ai > a0 && increase && decrease){
            count++;
            increase = false;
            decrease = false;
        }
        if(ai < a0 && increase && decrease){
            count++;
            increase = false;
            decrease = false;
        }
        a0 = ai;

    }
    cout << count + 1 << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 22 13:54:24 2020

@author: naoki
"""
import sys
#f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
N = int(input())
a = list(map(lambda x:int(x)-1,list(input())))
   
all_odd = 0
kai = [0] * N

if (0 not in a) and (1 not in a):
    print(0)
    sys.exit()
if (1 not in a) and (2 not in a):
    print(0)
    sys.exit()
if (0 not in a) and (2 not in a):
    print(0)
    sys.exit()
    
for k in range(1,N):
    count = 0
    p = k
    for _ in range(N):
        if p % 2 == 1:
            kai[k] = kai[k-1] + count
            break
        p = p/2
        count += 1

all_num = 0
for k in range(N):
    if kai[-1] == kai[k] + kai[N-1-k] and a[k] == 1:
        all_num += 1

if all_num % 2 == 1:
    print(1)
elif 1 in a:
    print(0)
else:
    for i in range(N):
        a[i] = a[i]/2
    for k in range(N):
        if kai[-1] <= kai[k] + kai[N-1-k] and a[k] == 1:
            all_num += 1
    if all_num % 2 == 1:
        print(2)
    else:
        print(0)

Measured memory_bytes: 148092
#include <bits/stdc++.h>
using namespace std;
long long a,b,ca,cb,r;
int main()
{
    cin>>a>>b;
    ca=a;
    cb=b;
    while(cb)
    {
        r=ca%cb;
        ca=cb;
        cb=r;
    }
    cout<<a*b/ca;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
	
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int n2;
		int divisor = 0;
		int div8 = 0;
		
		if (n % 2 == 0) {
			n = n - 1;
		}
		
		do {
		
			n2 = n;
			
			do {
			
				if (n % n2 == 0) {
					divisor = divisor + 1;
				}
				
				n2 = n2 - 1;
						
			} while (n2 >= 1);
				
				if (divisor == 8) {
					div8 = div8 + 1;
				}
		
				divisor = 0;
				n = n - 2;
							
		} while (n >= 1);
		
	System.out.println(div8);
		
	}

}

Measured memory_bytes: 23124
import sys
from itertools import product
if __name__ == "__main__":
    N, M = map(int, input().split())
    cakes = []
    for i in range(N):
      cakes.append(list(map(int, input().split(' '))))

    signs = (-1, 1)

    ans = 0
    for s1, s2, s3 in product(*([signs] * 3)):
        xs = [x1 * s1 + x2 * s2 + x3 * s3 for x1, x2, x3 in cakes]
        xs.sort()
        xs.reverse()
        ans = max(ans, sum(xs[:M]))
    print(ans)

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

int main() {
	int n,k,x,y,i,color,kari;
	cin>>n;
	cin>>k;
	for(i=0;i<k;i++){
		cin>>x;
		cin>>y;
	
		if(x>n/2){x=n-x+1;}
		if(y>n/2){y=n-y+1;}
		
		if(x<y){kari=x;x=y;y=kari;}
		
		color=y%3;
		if(color==0){color=3;}
		
		cout<<color<<endl;
	}
}

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

using namespace std;

int main(){

    int N, temp, sum = 0;

    cin >> N;
    int arr[N];

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

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N-i-1; j++){
            if(arr[j] > arr[j+1]){
                temp = arr[j];
                arr[j] = arr[j+1];
                arr[j+1] = temp;
            }
        }
    }


    for(int i = 0; i < N-1; i++){
        sum += abs(arr[i] - arr[i+1]);
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<deque>
 
using namespace std;
typedef long long ll;
 
int main(void)
{
    string S;
    cin >> S;

    char _s = S[0];
    for(int i = 1; i < S.size(); i++)
    {
        if(_s == S[i])
        {
            cout << "Bad" << endl;
            return 0;
        }
        _s = S[i];
    }

    cout << "Good" << endl;
}

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

using namespace std;

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

string fillzero(string s, int L) {
    int n = L - s.size();
    rep(i, n) s = "0" + s;
    return s;
}

int main() {
	while(1) {
	    string a; cin >> a;
	    int L; cin >> L;
	    if(a=="0" && L==0) break;
	    
	    a = fillzero(a, L);
	    
	    unordered_map<string, int> prev;
	    prev[a] = 0;
	    for(int i=1;; i++) {
	        string amin(a); sort(all(amin));
	        string amax(amin); reverse(all(amax));
	        string tmp = to_string(stoi(amax.c_str()) - stoi(amin.c_str()));
	        tmp = fillzero(tmp, L);
	        // cout << amax << "-" << amin << "=" << tmp << endl;
	        if(prev.count(tmp)) {
	            cout << prev[tmp] << " " << stoi(tmp.c_str()) << " " << i - prev[tmp] << endl;
	            break;
	        }
	        prev[a=tmp] = i;
	    }
	    // cout << "--------" << endl;
	}
}



Measured memory_bytes: 3248
///
// File:  alds1_12_c.cpp
// Author: ymiyamoto
//
// Created on Wed Oct 18 22:36:29 2017
//

#include <cstdint>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

#define SIZE 10000

struct route_t {
  uint32_t node;
  int64_t weight;

  bool operator<(const route_t &r) const
  {
    return weight > r.weight;
  }
};

static vector<route_t> graph[SIZE];
static int64_t costs[SIZE];
static bool visited[SIZE];
static priority_queue<route_t> q;

static void dikstra()
{
  q.push({0, 0});
  costs[0] = 0;

  while (!q.empty()) {
    route_t r = q.top();
    q.pop();

    if (!visited[r.node]) {
      visited[r.node] = true;
      for (uint32_t i = 0; i < graph[r.node].size(); i++) {
        int64_t cost = graph[r.node][i].weight;
        uint32_t node = graph[r.node][i].node;
        if (cost != -1) {
          if (costs[r.node] + cost < costs[node]) {
            costs[node] = costs[r.node] + cost;
            q.push({node, costs[node]});
          }
        }
      }
    }
  }
}

int32_t main()
{
  uint32_t n;
  cin >> n;

  for (uint32_t i = 0; i < n; i++) {
    costs[i] = INT32_MAX;
  }

  for (uint32_t i = 0; i < n; i++) {
    uint32_t id, k;
    cin >> id >> k;
    for (uint32_t j = 0; j < k; j++) {
      route_t r;
      cin >> r.node >> r.weight;
      graph[id].push_back(r);
    }
  }

  dikstra();

  for (uint32_t i = 0; i < n; i++) {
    cout << i << " " << costs[i] << endl;
  }

  return 0;
}

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

typedef long long ll;

int main(){
    int W, H, N;
    cin >> W >> H >> N;
    int area[W][H];
    for(int i=0;i<W;i++){
        for(int j=0;j<H;j++){
            area[i][j]=0;
        }
    }

    int check[3];

    for(int i = 0; i<N; i++){
        for(int j=0;j<3;j++){
            cin >> check[j];
        }
        if(check[2]==1){
            for(int i=0;i<check[0];i++){
                for(int j=0;j<H;j++){
                    area[i][j] = 1;
                }
            }
        }
        if(check[2]==2){
            for(int i=check[0];i<W;i++){
                for(int j=0;j<H;j++){
                    area[i][j] = 1;
                }
            }
        }
        if(check[2]==3){
            for(int i=0;i<W;i++){
                for(int j=0;j<check[1];j++){
                    area[i][j] = 1;
                }
            }
        }
        if(check[2]==4){
            for(int i=0;i<W;i++){
                for(int j=check[1];j<H;j++){
                    area[i][j] = 1;
                }
            }

        }
    }

    int result;
    for(int i = 0;i<W;i++){
        for(int j=0;j<H;j++){
            if(area[i][j]==0){
                result++;
            }
        }
    }

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


Measured memory_bytes: 256