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

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) (x & -(x))
#define BIT(a,b) ((ll)(a&(1<<b))==0 ? false : true)

const ll MAXN=2e5+10;
const ll INF=1e12+10;

ll n;

ll dpa[MAXN];
ll dpb[MAXN];
ll kal[MAXN];
ll kar[MAXN];
ll kbl[MAXN];
ll kbr[MAXN];

ll find_al(ll a)
{
    if (a==0)
    {
        return INF;
    }

    ll k=kal[a],p=LB(a);

    a-=LB(a);

    return min(k , find_al(a)+p);
}

ll find_ar(ll a)
{
    if (a>n)
    {
        return INF;
    }

    ll k=kar[a],p=LB(n-a+1);

    a+=LB(n-a+1);

    return min(k , find_ar(a)+p);
}

ll find_bl(ll b)
{
    if (b==0)
    {
        return INF;
    }

    ll k=kbl[b],p=LB(b);

    b-=LB(b);

    return min(k , find_bl(b)+p);
}

ll find_br(ll b)
{
    if (b>n)
    {
        return INF;
    }

    ll k=kbr[b],p=LB(n-b+1);

    b+=LB(n-b+1);

    return min(k , find_br(b)+p);
}

void update_al(ll a , ll x)
{
    dpa[a]=x;

    ll k=a;

    while (k<=n)
    {
        kal[k]=min(kal[k] , k-a+x);

        k+=LB(k);
    }
}

void update_ar(ll a , ll x)
{
    dpa[a]=x;

    ll k=a;

    while (k>0)
    {
        kar[k]=min(kar[k] , a-k+x);

        k-=LB(n-k+1);
    }
}

void update_bl(ll a , ll x)
{
    dpb[a]=x;

    ll k=a;

    while (k<=n)
    {
        kbl[k]=min(kbl[k] , k-a+x);

        k+=LB(k);
    }
}

void update_br(ll a , ll x)
{
    dpb[a]=x;

    ll k=a;

    while (k>0)
    {
        kbr[k]=min(kbr[k] , a-k+x);

        k-=LB(n-k+1);
    }
}

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

    ll q;
    cin>>n>>q;

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

    fill(dpa , dpa+MAXN , INF);
    fill(kar , kar+MAXN , INF);
    fill(kal , kal+MAXN , INF);

    dpa[a]=0;

    ll k=a;

    while (k<=n)
    {
        kal[k]=k-a;

        k+=LB(k);
    }

    k=a;

    while (k>0)
    {
        kar[k]=a-k;

        k-=LB(n-k+1);
    }

    fill(dpb , dpb+MAXN , INF);
    fill(kbr , kbr+MAXN , INF);
    fill(kbl , kbl+MAXN , INF);

    dpb[b]=0;

    k=b;

    while (k<=n)
    {
        kbl[k]=k-b;

        k+=LB(k);
    }

    k=b;

    while (k>0)
    {
        kbr[k]=b-k;

        k-=LB(n-k+1);
    }

    ll suma=0,sumb=0;

    for(ll i=1;i<=q;i++)
    {
        ll x;
        cin>>x;

        ll w=min(find_al(x) , find_ar(x))+suma;
        ll d=min(find_bl(x) , find_br(x))+sumb;

        suma+=abs(x-b);
        sumb+=abs(x-a);

        if ((w-sumb)<dpb[b])
        {
            update_bl(b , w-sumb);
            update_br(b , w-sumb);
        }

        if ((d-suma)<dpa[a])
        {
            update_al(a , d-suma);
            update_ar(a , d-suma);
        }

        a=x;
        b=x;
    }

    ll res=INF;

    for(ll i=1;i<=n;i++)
    {
        res=min(res , dpa[i]+suma);
        res=min(res , dpb[i]+sumb);
    }

    cout<<res;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int>Mochi(N);
  for(int i = 0; i < N; i++){
    cin >> Mochi.at(i); //配列に代入
  }

  sort(Mochi.begin(), Mochi.end());
  reverse(Mochi.begin(), Mochi.end());
  
  int number = 1; //鏡餅の段数の変数を定義
  for(int i = 0; i < N - 1; i++){
    if(Mochi.at(i) > Mochi.at(i + 1)){
      number += 1;
    }
    else{
      continue;
    }
  }
  cout << number << endl;
}


Measured memory_bytes: 256
n = gets.to_i
words = []
flag = true
for i in 1..n do
  word = gets.chomp
  first = word.split('')[0]
  last = first if i == 1
  if words.include?(word) || first != last
    flag =  false
  else
    last = word.split('')[-1]
    words << word
  end
end
puts flag == true ? "Yes" : "No"

Measured memory_bytes: 1916
import math
n = int(input())
towns = []


def cost_x(towns, i, j):
    return (towns[i][0] - towns[j][0]) ** 2


def cost_y(towns, i, j):
    return (towns[i][1] - towns[j][1]) ** 2


for i in range(0, n):
    towns.append(list(map(int, input().split())))

costs = 0
for i in range(0, len(towns)):
    for j in range(0, len(towns)):
        cost = 0
        if i == j:
            continue
        else:
            xs_cost = cost_x(towns, i, j)
            ys_cost = cost_y(towns, i, j)
            costs += math.sqrt((xs_cost + ys_cost))

print(costs/n)


Measured memory_bytes: 3064
n,k = map(int,input().split())
if k > n:
  k = n
a = list(map(int, input().split()))
dp = [0]*n
for i in range(1,n):
  if i <= k:
    dp[i] = abs(a[i]-a[0])
  else:
    dp[i] = min([abs(a[i]-a[i-j])+dp[i-j] for j in range(1,k+1)])
print(dp[-1])

Measured memory_bytes: 52856
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

class UnionFind{
public:
  vector<int> par;
  vector<int> rank;
  vector<int> sz;
  int N;

  UnionFind(int n){N=n;}

  //初期化
  void init(){
    for(int i=0;i<N;i++){
      par.push_back(i);
      rank.push_back(0);
      sz.push_back(1);
    }
  }

  //木の根を求める
  int find(int x){
    if(par[x]==x) return x;
    else{
      par[x]=find(par[x]);
      return par[x];
    }
  }

  //xとyの集合の併合
  void unite(int x, int y){
    x=find(x);
    y=find(y);
    if(x == y) return;

    if(rank[x] < rank[y]){
      par[x] = y;
      sz[y] += sz[x];
    }else{
      par[y] = x;
      sz[x] += sz[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

  //x,yが同じ集合にあるか
  bool same(int x, int y){
    return find(x) == find(y);
  }

  //xの木のサイズ
  int size(int x){
    return sz[find(x)];
  }
};

//-------------------------------------------------
int main(){
  int N,M;
  cin >> N >> M;
  int a[M],b[M];
  for(int i=0;i<M;i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }

  int cnt=0;
  for(int i=0;i<M;i++){
    UnionFind uf = UnionFind(N);
    uf.init();
    for(int j=0;j<M;j++){
      if(j!=i){
        uf.unite(a[j],b[j]);
      }
    }
    if(!uf.same(a[i],b[i])) cnt++;
  }

  cout << cnt << 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();
    int a = sc.nextInt();

    if(x < a) {
      System.out.println(0);
    } else {
      System.out.println(10);
    }

  }

}


Measured memory_bytes: 22996
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

bool is_valid(int h,int w,int i,int j){
    return 0<=i&&i<h&&0<=j&&j<w;
}

void run(){
    int w,h;
    cin>>w>>h;
    if(!w)return;
    vvi c(h,vi(w));
    rep(i,h)rep(j,w)cin>>c[i][j];
    bool visited[h][w]={};
    queue<pi> q;
    int ans=0;
    int dx[]={1,1,0,-1,-1,-1,0,1},dy[]={0,1,1,1,0,-1,-1,-1};
    rep(i,h){
        rep(j,w){
            if(c[i][j]){
                ans++;
                q.push({i,j});
                visited[i][j]=true;
                while(!q.empty()){
                    pi p=q.front();
                    q.pop();
                    int y=p.fi,x=p.se;
                    c[y][x]=0;
                    rep(k,8){
                        int ny=y+dy[k],nx=x+dx[k];
                        if(is_valid(h,w,ny,nx)&&c[ny][nx]&&!visited[ny][nx]){
                            visited[ny][nx]=true;
                            q.push({ny,nx});   
                        }
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    run();
}


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

#define ll unsigned long long
#define INF 1234567890
#define N (int)(2e5 + 5)
#define pi acos(-1)

void solve()
{
    int k, n, t[N];
    cin >> k >> n;
    for(int i = 1; i <= n; ++i) cin >> t[i];
    int maxim = t[1] + k - t[n];
    for(int i = 2; i <= n; ++i)
        maxim = max(maxim, t[i] - t[i - 1]);
    cout << k - maxim;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <string>
#define MAX_U   10
#define MIN_U   0
using namespace std;
void printa(){cout<<endl;}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int main(void){
    int a,b;
    cin >>a>>b;
    if(a>=13){
        exit(0);
    }
    else if(a>=12&&b>=12){
        printa(12);
        exit(0);
    }
    else if(a>=12){
        printa(11);
        exit(0);
    }
    else if(a>=11&&b>=11){
        printa(11);
        exit(0);
    }
    else if(a>=11){
        printa(10);
        exit(0);
    }
    else if(a>=10&&b>=10){
        printa(10);
        exit(0);
    }
    else if(a>=10){
        printa(9);
        exit(0);
    }
    else if(a>=9&&b>=9){
        printa(9);
        exit(0);
    }
    else if(a>=9){
        printa(8);
        exit(0);
    }
    else if(a>=8&&b>=8){
        printa(8);
        exit(0);
    }
    else if(a>=8){
        printa(7);
        exit(0);
    }
    else if(a>=7&&b>=7){
        printa(7);
        exit(0);
    }
    else if(a>=7){
        printa(6);
        exit(0);
    }
    else if(a>=6&&b>=6){
        printa(6);
        exit(0);
    }
    else if(a>=6){
        printa(5);
        exit(0);
    }
    else if(a>=5&&b>=5){
        printa(5);
        exit(0);
    }
    else if(a>=5){
        printa(4);
        exit(0);
    }
    else if(a>=4&&b>=4){
        printa(4);
        exit(0);
    }
    else if(a>=4){
        printa(3);
        exit(0);
    }
    else if(a>=3&&b>=3){
        printa(3);
        exit(0);
    }
    else if(a>=3){
        printa(2);
        exit(0);
    }
    else if(a>=2&&b>=2){
        printa(2);
        exit(0);
    }
    else if(a>=2){
        printa(1);
        exit(0);
    }
    else if(a>=1&&b>=1){
        printa(1);
        exit(0);
    }
    return 0;
}

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

int main() {
int A, B, C, D;
cin >> A >> B >> C >> D;

if(A + B > C + D) cout << "Left" << endl;
else if(A + B < C + D) cout << "Right" << endl;
else cout << "Balanced" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main()
{
    int N;
    vector<int> a;
    cin >> N;
    int tmp;
    for (int i=0; i<N; ++i)
    {
        cin >> tmp;
        a.push_back(tmp);
    }

    int ans = inf;
    int sumOfsquare = 0;
    for (int i=-100; i<101; ++i)
    {
        sumOfsquare = 0;
        for(int j=0; j<N; ++j)
        {
            sumOfsquare += (i-a[j])*(i-a[j]);    
        }
        if(sumOfsquare<ans) ans = sumOfsquare;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# include <algorithm>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <string>
# include <vector>

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s[n];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(s, s+n);
    ll cur = 1;
    ll ans = 0;
    for(int i = 1; i < n; i++) {
        if (s[i-1] == s[i]) {
            cur++;
            if (i == n-1) {
                ans += cur * (cur-1) / 2;
            }
        } else {
            if (cur > 1) {
                ans += cur * (cur-1) / 2;
                cur = 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    if (A <= C && C <= B) {
     System.out.println("Yes");
     } else {
      System.out.println("No");
     }
   }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

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

    int sum = 0;
    for (int i = 1; i < n / 2 + (n % 2); i++) {
        sum++;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf
#define itn int
using namespace std;
const int N=1e6;
const long long mod=1e9+7;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
ll mul(ll a,ll b,ll c){ll ans=0;for(;b;b>>=1,a=(a+a)%c)if(b&1)ans=(ans+a)%c;return ans;}
ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=mul(a,a,c))if(b&1)ans=mul(ans,a,c);return ans;}
int n,k;
int main(){	
	//freopen("in.txt","r",stdin);
	cin>>n>>k;
	int N=(n-1)*(n-2)/2;
	if(k>N)return o(-1);
	o(N-k+n-1);
	int cnt=N-k;
	for(int i=1;i<n;i++)cout<<i<<" "<<n<<endl;
	for(int i=1;i<n;i++)
	for(int j=i+1;j<n;j++){
		if(cnt>0){
			cout<<i<<" "<<j<<endl;
			cnt--;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> arr(n, 0);
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            arr[a - 1] += 1;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (arr[i] == 0) ans += 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL N=5010;
LL n, a, b, p[N], id[N], dp[N][N], s[N][N];
int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	for(LL i=1; i<=n; ++i)scanf("%lld",&p[i]), id[p[i]]=i;
	memset(s,0x3f,sizeof(s));
	for(LL i=0; i<=n; ++i)s[0][i]=0;
	for(LL i=1; i<=n; ++i)
		for(LL j=0; j<=n; ++j){
			dp[i][j]=s[i-1][j]+(j>=id[i]?a:b);
			if(j==id[i])dp[i][j]=min(dp[i][j],s[i-1][j-1]);
			if(j>0)s[i][j]=min(s[i][j-1],dp[i][j]);else s[i][j]=dp[i][j];
		}
	LL mn=0x3f3f3f3f3f3f3f3f;
	for(LL i=1; i<=n; ++i)mn=min(mn,dp[n][i]);
	printf("%lld",mn);
	return 0;
}

Measured memory_bytes: 392192
S = input()
#alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
alphabet = "abcdefghijklmnopqrstuvwxyz"

ans = "None"
for i in range(len(alphabet)):
    if(alphabet[i] not in S):
        ans = alphabet[i]
        break
    
print(ans)

Measured memory_bytes: 3188
n = int(input())
like_753 = []


def dfs(x):
    if n < x:
        return 0
    else:
        like_753.append(x)
        dfs(10*x+3)
        dfs(10*x+5)
        dfs(10*x+7)


dfs(3)
dfs(5)
dfs(7)

ls_753 = [x for x in like_753 if len(set(str(x))) == 3]
print(len(ls_753))


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

int main() {
  string s;
  int w;
  cin >> s >> w;
  string ans = "";
  for (int i = 0; i < (int)s.size(); ++i) {
    if (i % w == 0) ans += s[i];
  }
  cout << ans << endl;
}

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

#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)
#define scin(a) scanf("%d",&a);
#define scdo(a) scanf("%lf",&a);
#define scch(a) scanf("%s",a);
#define anin(a) printf("%d\n",a);
#define ando(a) printf("%lf\n",a);
#define anch(a) printf("%s\n",a);

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(void){
	int P,Q,R,max;
	scanf("%d %d %d",&P,&Q,&R);
	if(P > Q) max = P ; else max = Q;
	if(max < R) max = R;
	printf("%d\n",P + Q + R - max);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  long long N, A, B;
  cin >> N >> A >> B;
  long long ans = 0;
  if ((B - A) % 2 == 0)
  {
    ans = (B - A) / 2;
  }
  else
  {
    ans = min(A, N - B + 1);
    ans += (B - A - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    LL a,b;
    cin>>a>>b;
    cout<<(a*b)/(__gcd(a,b));

}


Measured memory_bytes: 3628
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
  int n;
  cin >> n;
  ll result = 0;
  for(int i = 1; i <= n; i++)
  {
    if(i % 3 != 0 && i % 5 != 0)
    {
      result += i;
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 3632
import Text.Printf
import Data.Char

main :: IO()
main = do
    [_,k] <- map read . words <$> getLine
    str <- getLine
    putStrLn $ getsolve str k

getsolve :: String -> Int -> String
getsolve str num = (take (num - 1) str) ++ [toLower (str !! (num - 1))] ++ (drop num str)




Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int n,a[100],evenNum;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) if(a[i]%2==0) evenNum++;
	cout<<pow(3,n)-pow(2,evenNum)<<endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
t=[]
x=[]
y=[]
for i in range(N):
    t1, x1, y1=map(int, input().split())
    t.append(t1)
    x.append(x1)
    y.append(y1)
for j in range (N):
    if t[j]%2==(x[j]+y[j])%2 and x[j]<=t[j] and y[j]<=t[j] and x[j]+y[j]<=t[j]:
        continue
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 11808
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 1000000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
typedef int64_t 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 N, M;
bool S[MAX_N];
int WA[MAX_N];

int main() {
	
	cin >> N >> M;
	
	int WAnum = 0;
	int ACnum = 0;
	rep(i, N)S[i] = true;
	rep(i, M) {
		int t;
		string j;
		cin >> t >> j;
		t--;
		if (S[t])
		{
			if (j == "WA") {
				WA[t]++;
			}else 
			{ 
				S[t] = false;
				WAnum += WA[t];
				ACnum++;
			}
		}
	}
	cout << ACnum << " " << WAnum << endl;
}

Measured memory_bytes: 4068
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int r,d;
	long long x;
	cin>>r>>d>>x;
	for(int i=1;i<=10;i++)
	{
		x=r*x-d;
		cout<<x<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
N, T = map(int,input().split())
CT = [list(map(int,input().split())) for i in range(N)]
ans = 1001
for i in range(N):
    if CT[i][1]<=T:
        ans = min(ans,CT[i][0])
if ans == 1001:
    print("TLE")
else: print(ans)

Measured memory_bytes: 3060
from operator import itemgetter
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
bc = []
for i in range(m):
	bi,ci = list(map(int,input().split()))
	bc.append([bi,ci])
bc = sorted(bc,key=itemgetter(1))
# print("bc=",bc)
a = sorted(a)
# print("a=",a)
count = n
apos = n-1
bcpos = m-1
ans = 0
while(count>0):
	if(bcpos<0 or a[apos]>=bc[bcpos][1]):
		# print("1",ans,apos,count)
		ans+=a[apos]
		apos-=1
		count-=1
		# print("1",ans,apos,count)
	else:
		temp = min(count,bc[bcpos][0])
		# print("2",temp,ans,bcpos,count)
		ans+=(temp*bc[bcpos][1])
		bcpos-=1
		count-=temp
		# print("2",temp,ans,bcpos,count)
print(ans)


Measured memory_bytes: 26452
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int n,k;
LL a[Max],f[Max];
LL suma[Max],sumf[Max];
int lena=1,lenf=1;
bool cmp(LL a,LL b){
    return a>b;
}
LL fun()
{
    LL ans=1e12+5;
    for(int i=1;i<lenf;i++)
        sumf[i]=sumf[i-1]+abs(f[i])-abs(f[i-1]);

    for(int i=1;i<lena;i++)
        suma[i]=suma[i-1]+a[i]-a[i-1];

    for(int i=0;i<=k;i++)
    {
        if(i<lena && (k-i)<lenf){
            ans=min(ans,suma[i]*2+sumf[k-i]);
            ans=min(ans,suma[i]+sumf[k-i]*2);
        }
    /*    if((k-i)<lena && i<lenf)
        {
            ans=min(ans,sumf[i]*2+suma[k-i]);
            ans=min(ans,sumf[i]+suma[k-i]*2);
        }*/
    }
    return ans;
}
int main()
{
    LL x;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%lld",&x);
        if(x<0){
             f[lenf++]=x;
        }else{
             a[lena++]=x;
        }

    }
    sort(f+1,f+lenf,cmp);
    printf("%lld\n",fun());
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N];
		for (int i=0;i<N;i++) {
			a[i] = sc.nextInt();
		}
		int now =1;
		int count =0;
		while (now!=2) {
			if (count>N) {
				break;
			}
			now = a[now-1];
			count++;
		}
		if (count>N) {
			System.out.println(-1);
		} else {
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 53116
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>

#define rep(i,n) for(int (i)=0;i < (n);(i)++)
#define ll long long
#define INF 9223372036854775807

using namespace std;

// input
int x;

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

  ll ans = 0;
  cin >> x;

  ans += (x/500) * 1000;
  x -= (x/500)  * 500;
  ans += (x/5) * 5;
  cout << ans;
}



Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<string.h>
#include<math.h>
#include<cassert>
#include<iomanip>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<functional>
#include<algorithm>
#include<assert.h>
#include<numeric>
#include<limits.h>
using namespace std;
int n,m1,m2;
int a[45],b[45],c[45];
map<int,int>mp,mp1;
int main()
{
	scanf("%d%d%d",&n,&m1,&m2);
	for(int i=0;i<n;i++)
	{
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
		b[i]=b[i]*m1-a[i]*m2;
	}
	for(int i=0;i<n;i++)
	{
		mp1=mp;
		for(int j=-8000;j<=8000;j++)
		{
			if(mp[j]==0)continue;
			if(mp[j+b[i]]==0)mp1[j+b[i]]=mp[j]+c[i];else mp1[j+b[i]]=min(mp[j+b[i]],mp[j]+c[i]);
		}
		if(mp[b[i]]!=0)mp1[b[i]]=min(mp[b[i]],c[i]);else mp1[b[i]]=c[i];
		mp=mp1;
	}
	if(mp[0]==0)printf("-1\n");else printf("%d\n",mp[0]);
	return 0;
}

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

int main() {
	string s, t;
	int i;
	cin >> s >> t;
	for (i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			cout << "No\n";
			break;
		}
	}
	if (i == s.size()) {
		cout << "Yes\n";
	}
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n;
    ll ans = 1;
    vector<ll> a(26, 1);
    string s;
    cin >> n >> s;
    rep(i, n)++a[s[i]-'a'];
    rep(i, 26){
        ans = ans * a[i];
        ans = ans % mod;
    }
    cout << ans - 1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 10000005

ll f[MAX_N] = {};
int main() {
    ll n;
    cin >> n;

    ll ans = 0;
    srep(i,1,n+1){
        int ii = i;
        while(ii <= n){
            ans += ii;
            // f[ii]++;
            ii += i;
        }
    }

    /*
    srep(i,1,n+1){
        ll ii = i;
        ans += f[i] * ii;
    }
    */
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3620
using System;
 

class TtoT{
    static void Main(string[] args){
        int n,a,b;
        string[] input;

        input = Console.ReadLine().Split(' ');
        n = int.Parse(input[0]);
        a = int.Parse(input[1]);
        b = int.Parse(input[2]);

        int output;

        output = n*a < b ? n*a : b;
        
        Console.WriteLine(output);

    }
}

Measured memory_bytes: 11092
N = int(input())
E = [tuple(map(int, input().split())) for _ in range(N - 1)]

res = 0

for i in range(N):
    res += (i + 1) * (N - i)

for i in range(N - 1):
    u, v = E[i]
    if v < u:
        u, v = v, u
    res -= u * (N - v + 1)

print(res)

Measured memory_bytes: 99124
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

//問題文が複雑な時は具体例を出して、小さい方から考えていく
//形だけが同じなら良くて、a~前の文字列で使った一番大きい文字+1が次の文字列で使える
//あとは形が同じでその中の辞書順最強をdfsで作っていく

int N;
string s = "";

void dfs(int v){
    //N文字になるまで
    if(v == N){
        fin(s);
        return;
    }
    
    
    //現在使える一番大きい文字
    char currentBigAlpha = 'a';
    
    //sからbiggestを探す
    while(s.find(currentBigAlpha) != string::npos){
        //aから初めてその文字列の一番大きいやつを探す
        currentBigAlpha++;
    }
    //次で+1してるので--しておく
    currentBigAlpha--;

    for(char c='a';c<=currentBigAlpha+1;c++){
        s.push_back(c);
        //全列挙のときdfsを使うのはここでN=3だったら最初にaaaまでいってもどったときにsをpopして次にaabをして
        //その次はab→aba→abb→abcとやるから、popが便利！
        dfs(v+1);
        s.pop_back();
    }

}
int main(){
      cin >> N;
      dfs(0);
      
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N,Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	vector< int > cnt(N+1, 0);
	for (int i=1; i<N; i++) {
		cnt[i+1] = cnt[i];
		if (S[i] == 'C' && S[i-1] == 'A') cnt[i+1]++;
	}
	// for (
	for (int i=0; i<Q; i++) {
		int L,R;
		cin >> L >> R;
		cout << cnt[R] - cnt[L] << '\n';
	}
	return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#define plll pair <ll, pair <ll, ll>>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()
#define vvl vector <vector <ll> >
 
typedef long long ll;
 
typedef long double ld;
 
using namespace std;
 
const ll maxn = 1e3 + 100;

ll n, m, k, t;

ll A[maxn][maxn];

ll geti(ll x) {
    return x / m;
}

void output() {
    ll q, w;
    for (q = 0; q < n; q++) {
        for (w = 0; w < m; w++) {
            cout << A[q][w] + 1 << " ";
        }
        cout << endl;
    }
}

vector <ll> V[maxn];

ll R[maxn];

set <ll> S[maxn];

bool used[maxn];

bool dfs(ll v) {
    used[v] = 1;
    for (auto v1 : V[v]) {
        if (R[v1] == -1) {
            R[v1] = v;
            return 1;
        }
    }
    for (auto v1 : V[v]) {
        if (!used[R[v1]]) {
            if (dfs(R[v1])) {
                R[v1] = v;
                return 1; 
            }
        }
    }
    return 0;
}

bool cmp(ll a, ll b) {
    return geti(a) < geti(b);
}

int main() {
    pyshnapyshnakaa;
    ll q, w, e, a, b, c;
    cin >> n >> m;
    vector <map <ll, vector <ll> > > M(n);
    for (q = 0; q < n; q++) {
        for (w = 0; w < m; w++) {
            cin >> A[q][w];
            A[q][w]--;
            M[q][geti(A[q][w])].pb(A[q][w]);
        }
    }
    for (q = 0; q < m; q++) {
        for (w = 0; w < n; w++) { // color
            V[w].clear();
            R[w] = -1;
            for (e = 0; e < n; e++) {
                if (!M[e][w].empty()) {
                    V[w].pb(e);
                }
            }
        }
        for (w = 0; w < n; w++) {
            for (e = 0; e < n; e++) {
                used[e] = 0;
            }
            dfs(w);
        }
        for (w = 0; w < n; w++) {
            ll c = R[w];
            A[w][q] = M[w][c].back();
            M[w][c].pop_back();
        }
    }
    output();
    for (q = 0; q < m; q++) {
        vector <ll> X;
        for (w = 0; w < n; w++) {
            X.pb(A[w][q]);
        }
        sort(all(X));
        for (w = 0; w < n; w++) {
            A[w][q] = X[w];
        }
    }
    output();
    return 0;
}


Measured memory_bytes: 5332
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , q ;

int main ( ){
  scanf("%d %d",&q,&n);
  int tony = 1 ;
  for ( int i = 1 ; i <= n ;i++ ){
    if ( tony%100 == 0 ){
        i-- ;

    }
    tony++;
  }
  tony --;
  while ( q-- ){
    tony*=100;
  }
printf("%d",tony );
return 0 ;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n=int(input())
x=input()

ones=x.count("1")

a=ones+1
b=ones-1

xda=0
xdb=0
for i in range(n):
    if x[-1-i]=="1":
        xda+=pow(2,i,a)
        xda%=a
        if b==0:
            continue
        xdb+=pow(2,i,b)
        xdb%=b

xds=[-1]*n

for i in range(n):
    if x[-1-i]=="0":
        xds[-1-i]=(xda+pow(2,i,a))%a
    else:
        if b==0:
            continue
        xds[-1-i]=(xdb-pow(2,i,b))%b

    
def popcount(x):
    return bin(x).count("1")
    
def solve(x):
    if x<0:
        return -1
    if x==0:
        return 0
    cnt=0
    while x>0:
        cnt+=1
        x=x%popcount(x)
    return cnt

for xd in xds:
    print(1+solve(xd))



Measured memory_bytes: 17472
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#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 FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define _GLIBCXX_DEBUG

int threemax(int a, int b, int c) {
	if (a >= b && a >= c) {
		return a;
	}
	else if (b >= a && b >= c) {
		return b;
	}
	else {
		return c;
	}
}

int threemin(int a, int b, int c) {
	if (a <= b && a <= c) {
		return a;
	}
	else if (b <= a && b <= c) {
		return b;
	}
	else {
		return c;
	}
}

void chmaxl(ll &a,ll b){
	if(a<b){
		a=b;
	}
	return;
}

void chminl(ll &a,ll b){
	if(a>b){
		a=b;
	}
	return;
}

void chmaxi(int &a,int b){
	if(a<b){
		a=b;
	}
	return;
}

void chmini(int &a,int b){
	if(a>b){
		a = b;
	}
	return;
}



int main() {
  ll N;
  cin >> N;
  vector<ll> vec(N);
  vector<ll> kosuu(100010);
  ll sum=0;
  for(ll i=0;i<N;i++){
    cin >> vec.at(i);
    kosuu.at(vec.at(i))++;
    sum+=vec.at(i);
  }
  ll Q;
  cin >> Q;
  for(ll i=0;i<Q;i++){
    ll B,C;
    cin >> B >> C;
    cout << sum-(B-C)*kosuu.at(B) << endl;
    sum=sum-(B-C)*kosuu.at(B);
    kosuu.at(C)+=kosuu.at(B);
    kosuu.at(B)=0;
  }
}

Measured memory_bytes: 4756
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main(void) {
      int a, b, c;

      if(scanf("%d %d %d", &a, &b, &c) == 1);

      if((c > a && c < b) || (c < a && c > b)) {
            printf("Yes");
      } else {
            printf("No");
      }

      return 0;
}

Measured memory_bytes: 128
N=int(input())
S=dict()
for i in range(N):
	tmp=input()
	if tmp in S:
		S[tmp]+=1
	else:
		S[tmp]=1
M=int(input())
T=dict()
for i in range(M):
	tmp = input()
	if tmp in T:
		T[tmp]+=1
	else:
		T[tmp]=1
ans=0
for SS in S:
	tmp = 0
	if SS in T:
		tmp=S[SS]-T[SS]
	else:
		tmp=S[SS]
	if tmp > ans:
		ans = tmp
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		boolean canArrive = true;
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int t1 = 0, t2;
			int x1 = 0, x2;
			int y1 = 0, y2;

			for (int i = 0; i < n; i++) {
				t2 = scanner.nextInt();
				x2 = scanner.nextInt();
				y2 = scanner.nextInt();

				int time = t2 - t1;
				int distance = Math.abs(x2 - x1) + Math.abs(y2  - y1);
				if (distance > time || (distance + time) % 2 == 1) {
					canArrive = false;
					break;
				}

				t1 = t2;
				x1 = x2;
				y1 = y2;
			}
		}

		if (canArrive) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 85096
'use strict'

function solve(S, T) {
  var dp = new Array(S.length + 1).fill(0).map(e => new Array(T.length + 1).fill(''))
  for (var i = 1; i <= S.length; i++) {
    for (var j = 1; j <= T.length; j++) {
      if (S[i-1] === T[j-1]) {
        dp[i][j] = dp[i-1][j-1] + S[i-1]
      } else {
        var s = dp[i][j-1].length > dp[i-1][j].length ? dp[i][j-1] : dp[i-1][j]
        dp[i][j] = s
      }
    }
  }
  return dp[S.length][T.length]
}

function main(input) {
  var lines = input.split("\n")
  var S = lines[0]
  var T = lines[1]
  var ans = solve(S,T)
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int x1=in(),y1=in(),x2=in(),y2=in();
	int dx=x2-x1,dy=y2-y1;
	int x3=x2-dy,y3=y2+dx;
	int x4=x3-dx,y4=y3-dy;

	cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
	return 0;
}


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

ll dp[110][5];

int main(){
    dp[0][0] = 1;
    dp[1][0] = dp[1][1] = 1;
    for(int i = 2; i <= 105; i++){
        dp[i][0] = 1;
        for(int j = 1; j < 5; j++){
            dp[i][j] = dp[i-1][j-1] + dp[i-1][j];
        }
    }
    string s; cin >> s;
    int k; cin >> k;
    int sz = s.size(), s_top = s[0] - '0';
    ll ans = 0;
    for(int i = k; i < sz; i++){
        ans += pow(9,k)*dp[i-1][k-1];
    }
    ans += (s_top-1)*pow(9,k-1)*dp[sz-1][k-1];
    if(k == 1) ans++;
    else if(k == 2){
        int cnt, num;
        bool ok = false;
        for(int i = 1; i < sz; i++){
            if(s[i] != '0'){
                cnt = i+1;
                num = s[i] - '0';
                ok = true;
                break;
            }
        }
        if(ok) ans += num + 9*(sz - cnt);
    }
    else{
        int cnt1 = 0, num1 = 0, cnt2 = 0, num2 = 0;
        bool ok1 = false, ok2 = false;;
        for(int i = 1; i < sz; i++){
            if(s[i] != '0' && cnt1 != 0){
                cnt2 = i+1;
                num2 = s[i] - '0';
                ok2 = true;
                break;
            }
            if(s[i] != '0' && cnt1 == 0){
                cnt1 = i+1;
                num1 = s[i] - '0';
                ok1 = true;
            }
        }
        if(ok1) ans += 9*(sz - cnt1)*(num1-1) + dp[sz - cnt1][2]*9*9; //位置cnt1が1~(num1-1)の場合 + 位置cnt1が0の場合
        if(ok2) ans += num2 + 9*(sz - cnt2); //位置cnt1はnum1の時、 位置cnt2が1~(num2-1)の場合 + 位置cnt2が0の場合
    }
    cout << ans << endl;
}

Measured memory_bytes: 4036
#include<iostream>
using namespace std;
main()
{
    //fast
    int tc=1,i,j,k;
//    cin>>tc;
    while(tc--)
    {
       int a;
       cin>>a;
       int s=0;
       while(s<a)
        s+=1000;
       cout<<s-a<<endl;
    }
}




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

using namespace std;

const int N = (int) 1e5;
int a[N];
int b[N];
int c[N];
int dp[3][N];
int n;

int main() {
    ios_base::sync_with_stdio(false);

    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];

    for (int i = 1; i < n; i++) {
        dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a[i];
        dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + b[i];
        dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + c[i];
    }

    int ans = 0;
    ans = max(ans, dp[0][n - 1]);
    ans = max(ans, dp[1][n - 1]);
    ans = max(ans, dp[2][n - 1]);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int sort(const void *a, const void *b){
    if( *(long long int*)a - *(long long int*)b < 0 )
        return -1;
    if( *(long long int*)a - *(long long int*)b > 0 )
        return 1;
    return 0;
}

int main(void){
    int n,m;
    scanf("%d%d",&n,&m);
    long long sum[n+2],ans=0;
    int a[n+2];
    sum[0]=0;
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        sum[i+1]=(sum[i]+a[i])%m;
    }
    qsort (sum,n+1,sizeof(long long),sort);
    long long count=1;
    for (int i=0; i<n; i++){
        if (sum[i]==sum[i+1]){
            count++;
        } else {
            if(count>1){
                ans+=count*(count-1)/2;
                count=1;
            }
        }
    }
    ans+=count*(count-1)/2;
    printf("%lld\n",ans);
	return 0 ;
}


Measured memory_bytes: 2172
#include <iostream>
using namespace std;
int main()
{
  int a,b,c,d;
  cin >> a >> b >> c;
  if (a>b) {
    d=a;
    a=b;
    b=d;
  }
  else {} 
  
  if (b>c) {
    d=b;
    b=c;
    c=d;
  }
  else {}
  
  if (a>b) {
    d=a;
    a=b;
    b=d;
  }
  else {}
  
  cout << a <<" "<< b <<" "<< c << endl;
  return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
if(s[0]==s[1]&&s[1]==s[2]){
  cout<<"Yes"<<endl;
}else if(s[1]==s[2]&&s[2]==s[3]){
  cout<<"Yes"<<endl;
}else{
  cout<<"No"<<endl;
}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
using namespace std;
int main() {
	int a[3] = {1, 0, 0};
	unsigned char c1, c2;
	while(scanf("%c,%c", &c1, &c2) != EOF) {
		swap(a[c1 - 'A'], a[c2 - 'A']);
	}
	printf("%c\n", a[0] * 'A' + a[1] * 'B' + a[2] * 'C');
}

Measured memory_bytes: 972
#[allow(unused_imports)]
use proconio::{input, fastout};
#[allow(unused_imports)]
use proconio::marker::{Chars};

#[fastout]
fn main() {
  input! {
    n:usize,d:f64,
    x:[(f64,f64);n]
  }
  let mut ans:u64 = 0;
  for i in 0..n {
    if (x[i].0*x[i].0 + x[i].1*x[i].1).sqrt() <= d {
      ans += 1;
    }
  }
  println!("{}",ans)
}


Measured memory_bytes: 7884
import itertools

if __name__ == '__main__':

	n = int(input())

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

	C  = [i for i in range(1,n+1)]
	D = [v for v in itertools.permutations(C, n)]

	a = D.index(A)
	b = D.index(B)

	print(abs(a-b))


Measured memory_bytes: 7924
N, M, X = map(int, input().split())

A = [[] for i in range(N)]
C = [0] * N
for i in range(N):
    c_as = list(map(int, input().split()))
    C[i], A[i] = c_as[0], c_as[1:]

INF = 10**9
ans = INF
for s in range(0, 1 << N):
    smart = [0] * M
    cost_sum = 0
    for i in range(N):
        if (s >> i) % 2 == 0:
            continue
        cost_sum += C[i]
        for j in range(M):
            smart[j] += A[i][j]
    ok = True
    for j in range(M):
        if smart[j] < X:
            ok = False
    if ok:
        ans = min(ans, cost_sum)
if ans == INF:
    ans = -1
print(ans)


Measured memory_bytes: 9244
from collections import deque

n, m = map(int, input().split())
eg = [[] for _ in range(n + 1)]

for _ in range(m):
    a, b = map(int, input().split())
    eg[a].append(b)
    eg[b].append(a)

xs = [0] * (n + 1)
q = deque()
q.append(1)
seen = {1}
while len(q) > 0:
    v = q.popleft()
    for t in eg[v]:
        if t in seen:
            continue
        q.append(t)
        seen.add(t)
        xs[t] = v
print("Yes")
print(*xs[2:], sep="\n")


Measured memory_bytes: 110632