akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, t;
int a[200000];

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

  cin >> n >> t;

  REP(i, n) {
    cin >> a[i];
  }

  ll ans = 0;
  REP(i, n - 1) {
    ans += min(t, a[i + 1] - a[i]);
  }
  ans += t;

  cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner a = new Scanner(System.in);
        int n = a.nextInt();
        int A[] = new int[n];
        for(int i=0; i<n; i++){
            A[i] = a.nextInt();
        }
        int minj;
        int count = 0;
        for(int i=0; i<=n-2; i++){
            minj = i;
            int c=0;
            for(int j=i+1; j<=n-1; j++){
                if(A[j] < A[minj]){
                    minj = j;
                    c = 1;
                }
            }
            if(c==1){
                int x = A[i];
                A[i] = A[minj];
                A[minj] = x; 
                count++;
            }
        }
        for(int i=0; i<n; i++){
            System.out.print(A[i]);
            if(i<n-1){
                System.out.print(" ");
            }
        }
        System.out.println();
        System.out.println(count);
    }
}


Measured memory_bytes: 26388
def resolve():
    n, m = map(int, input().split())
    ab = list(list(map(int, input().split())) for _ in range(n))
    cd = list(list(map(int, input().split())) for _ in range(m))
    for a, b in ab:
        p = min(cd, key=lambda x: abs(x[0] - a) + abs(x[1] - b))
        print(cd.index(p) + 1)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 39280
import java.util.Scanner;

public class Main {
	public static Scanner scanner;
	public static void main(String[] args) {
		scanner = new Scanner(System.in);
		int W = scanner.nextInt();
		int H = scanner.nextInt();
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		int r = scanner.nextInt();

		while(x < -100 || 100 < x);
		while(y < -100 || 100 < y);
		while(W < 0 || 100 < W);
		while(H < 0 || 100 < H);
		while(r < 0 || 100 < r);

		if(r <= x && x <= (W-r) && r <= y && y <= (H-r)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}



Measured memory_bytes: 26376
#include<iostream>
#include<cstdio>
using namespace std;
int n=0;//頂点数 ○
int u=0;//頂点の番号　○
int k[101]={0};//頂点番号の値　○
int v[101][101]={0};//??
int d[101]={0};//shortest ○
int fptr=0;//デキューをするための変数　○
int lptr=0;//エンキューをするための変数　○
int u1[10000];//頂点の番号　○
int d1[10000];//頂点への最短距離　○
int id=0;//i==id.　○
void enqueue(int u2,int d2)
{
	u1[lptr]=u2;//頂点の番号はu2
	d1[lptr]=d2;//頂点への最短距離はd2
	lptr=(lptr+1)%10000;//今何番目の配列か求める
}
void bfs(void)
{
	int u3;
	int d3;

	while(fptr!=lptr)
	{
		u3=u1[fptr];//頂点番号代入
		d3=d1[fptr];//最短距離代入
		fptr=(fptr+1)%10000;
		if(d[u3]!=-1)
		{
			continue;
		}
		for(int i=0;i<k[u3];i++)
		{
			enqueue(v[u3][i],d3+1);
		}
		d[u3]=d3;
	}
	/*
	bfsの引数は二つ→それぞれをu1[fptr]、d1[fptr]に代入
	1.whileで全体を回す（条件付）
	2.デキューをする（whileの直後）
	3.最短距離が更新されてなければcontinue（条件付）	
	4.enqueue（for文で回す）
	*/
}
int main(void)
{	
	scanf("%d",&n);//頂点数を決める
	for(int i=0;i<n;i++)//0が頂点数になるまで
	{
		scanf("%d",&u);//各頂点の隣接リスト入力 1:u=%d...%d(n):u=%d
		scanf("%d",&k[u]);//配列ｋ[u]に値を入れる 1:k[1]=%d...k[u]=%d
		for(int j=0;j<k[u];j++)//j<k[u]のとき
		{
			scanf("%d",&v[u][j]);//配列ｖ[頂点の番号][]に値を入れる
		}
	}
	enqueue(1,0);
	for(int i=0;i<n+1;i++)//全ての値を未探索にする
	{
		d[i]=-1;//未探索の値
	}
	bfs();
	for(int i=1;i<=n;i++)
	{
	printf("%d %d\n",i,d[i]);
	}
	return 0;
}


Measured memory_bytes: 3260
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int A,B;
    cin >> A >> B;
    fin((A*3+B)/2);
    return 0;
}

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

struct node{
	unsigned int key;
	struct node *next;
	struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch( int key )
{
	NodePointer cur = nil->next;
	while( 1 ) {
		if( cur == nil ) { break; }
		if( cur->key == key ) { break; }
		cur = cur->next;
	}
	return cur;
}

void init( )
{
	nil = malloc( sizeof(struct node) );
	nil->next = nil;
	nil->prev = nil;
}

void printList( )
{
	NodePointer cur = nil->next;
	int isf = 1;
	while(1) {
		if( cur == nil ) { break; }
		if( isf == 0) { printf(" "); }
		printf( "%d", cur->key );
		cur = cur->next;
		isf = 0;
	}
	printf("\n");
}

void deleteNode( NodePointer t )
{
	NodePointer pt = t->prev;
	NodePointer nt = t->next;
	pt->next = nt;
	nt->prev = pt;
	free( t );
}

void deleteFirst( )
{
	NodePointer t = nil->next;
	if( t == nil ) return;
	deleteNode( t );
}

void deleteLast( )
{
	NodePointer t = nil->prev;
	if( t == nil ) return;
	deleteNode( t );
}

void delete( int key )
{
	NodePointer cur = nil->next;
	while( 1 ) {
		if( cur == nil ) { break; }
		if( cur->key == key ) { break; }
		cur = cur->next;
	}
	if( cur == nil ) return;
	deleteNode( cur );
}


void insert( int key )
{
	NodePointer x;
	x = malloc( sizeof(struct node) );
	x->key = key;
	x->next = nil->next;
	x->next->prev = x;
	x->prev = nil;
	nil->next = x;
}


int main( int argc, char *argv[] ) 
{
	int key, n, i;
	char com[20];
	
	scanf( "%d", &n );
	init( );
	for( i = 0; i < n; i++ ) {
		scanf( "%s", com );
		if( com[0] == 'i' ) {
			scanf( "%d", &key );
			insert( key ); 
		} else if( com[0] == 'd' ) {
			if( 6 < strlen( com )  ) {
				if( com[6] == 'F' ) { 
					deleteFirst( );
				} else if( com[6] == 'L' ) {
					deleteLast( );
				}
			} else {
				scanf( "%d", &key );
				delete( key );
			}
		}
	}
	printList( );
	
    return 0;
}

Measured memory_bytes: 31788
n, k = map(int, input().split())
A = list(map(int, input().split()))
tmp = 1
route = [tmp]
edge = {tmp}

for i in range(1, k + 1):
    tmp = A[tmp - 1]
    if tmp in edge:
        left = route.index(tmp)
        right = len(route)
        idx = left + (k - left) % (right - left)
        print(route[idx])
        break
    else:
        route.append(tmp)
        edge.add(tmp)
        continue
else:
    print(tmp)

Measured memory_bytes: 113736
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

#define MOD 1000000007

long long factorial[200010] = {};
long long fact_inv[200010] = {};
long long inv[200010] = {};
int N = 200001;

long long power(long long n, int p) {
  if (p == 0) {
    return 1;
  }
  if (p == 1) {
    return n % MOD;
  }
  long long s;
  s = power(n, p/2);
  if (p % 2 == 0) {
    return s*s % MOD;
  }
  if (p % 2 == 1) {
    return n*power(n, p-1) % MOD;
  } else {
    return 0;
  }
}

void calc() {
  //printf("calc called\n");
  inv[1] = 1;
  for (int i = 2; i <= N; i++) {
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
  }
  factorial[0] = 1;
  fact_inv[0] = 1;
  for (int i = 1; i <= N; i++) {
    factorial[i] = (factorial[i - 1] * i) % MOD;
    fact_inv[i] = (fact_inv[i - 1] * inv[i]) % MOD;
  }
  //printf("calc fin\n");
}

long long combi(long long n, int p) {
  if (p > n || p < 0) {
    return 0;
  } else {
    return (((factorial[n] * fact_inv[p]) % MOD) * fact_inv[n-p]) % MOD;
  }
}

map<int, int> prime_factor(int n) {
  map<int, int> res;
  for (int i = 2; i*i <= n; i++) {
    while (n%i == 0) {
      res[i] += 1;
      n = n/i;
    }
  }
  if (n != 1) {
    res[n] += 1;
  }
  return res;
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  map<int, int> ans_1 = prime_factor(m);
  /*printf("\n");
  for (pair<int, int> x: ans_1) {
    printf("(%d %d) ", x.first, x.second);
  }
  printf("\n");
  */
  calc();
  long long ans = 1;
  for (pair<int, int> x: ans_1) {
    //printf("(%d %d) ", x.first, x.second);
    ans = (ans * combi(n+x.second-1, n-1)) % MOD;
  }
  printf("%lld", ans);
  return 0;
}


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

using namespace std;

int main()
{
  int n;
  bool ans = false;

  scanf("%d", &n);

  for (int i = 0; i <= 14; i++)
  {
    for (int j = 0; j <= 25; j++)
    {
      if (7 * i + 4 * j == n)
      {
        ans = true;
      }
    }
  }

  cout << (ans ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	string str;
	int flag = 0;
	while(cin >> str)
	{
		if(flag++ != 0) cout << endl;
		deque<string> res;

		rep(i, 5)
		{
			if(str.size() <= i)
				res.push_front("* = ****");
			else
			{
				if(str[i] - '0' < 5)
					res.push_back("* =");
				else
				{
					str[i] -= 5;
					res.push_back(" *=");
				}

				rep(j, str[i] - '0')
					res[i] += "*";

				res[i] += " ";

				rep(j, 5 - (str[i] - '0' + 1))
					res[i] += "*";
			}
		}

		rep(i, 8) rep(j, 5)
			cout << res[j][i] << (j == 4 ? "\n" : "");
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

template<class iterato>
int sorted(iterato first, iterato last) {
    for (auto iter = first; iter != last-1; iter++) {
        if (*iter > *(iter+1)) {
            return iter - first + 1;
        }
    }
    return -1;
}

int main() {
    int n = 0, k = 0;
    cin >> n >> k;
    vector<int> p(n);
    for (int i=0; i<n; i++) {
        cin >> p.at(i);
    }
    set<int> se;
    for (int i=0; i<k; i++) {
        se.insert(p.at(i));
    }
    int cnt = 1;
    for (int i=0; i<n-k; i++) {
        auto iter1 = se.begin();
        auto iter2 = se.end();
        iter2--;
        if (p.at(i) != *iter1 || p.at(i+k) < *iter2) {
            cnt++;
        }
        se.erase(p.at(i));
        se.insert(p.at(i+k));
    }
    se.clear();
    vector<int> soo;
    for (int i=0; i<k; i++) {
        se.insert(p.at(i));
    }
    int i = 0;
    while (i < n-k) {
        int tmp = sorted(p.begin()+i, p.begin()+i+k);
        if (tmp == -1) {
            soo.push_back(i);
            auto iter1 = se.begin(), iter2 = se.end();
            iter2--;
            int one = *iter1, two = *iter2;
            while (i < n-k && one == p.at(i) && p.at(i+k) > two) {
                se.erase(p.at(i));
                se.insert(p.at(i+k));
                i++;
                soo.push_back(i);
                auto iter1 = se.begin(), iter2 = se.end();
                iter2--;
                one = *iter1, two = *iter2;
            }
            i++;
        }
        else {
            i += tmp;
        }
    }
    if (sorted(p.begin()+n-k, p.end()) == -1) {
        soo.push_back(n-k);
    }
    if (soo.size() > 0) {
        sort(soo.begin(), soo.end());
        for (int i=0; i<soo.size()-1; i++) {
            if (soo.at(i+1) - soo.at(i) >= k) {
                cnt--;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using p  = pair<int, int>;
using vec_int = vector<int>;
using vec_str = vector<string>;
#define INF (1<<29)
ll ans = 0;

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

void debug_input(vec_str& argv)
{
    // デバッグ用引数読み込み
    ifstream file("./input.txt");
    string str;
    while( getline(file, str) ) {
        argv.push_back(str);
    }
}

void debug_split_string(const string& str, vec_str& v)
{
    stringstream ss{str};
    string buf;
    while (getline(ss, buf, ' ')) {
        v.push_back(buf);
    }
}

void debug_split_int(const string& str, vec_int& v)
{
    stringstream ss{str};
    string buf;
    while (getline(ss, buf, ' ')) {
        istringstream ss(buf);
        int temp;
        ss >> temp;
        v.push_back(temp);
    }
}

int main()
{
    int N = 0;
    cin >> N;
    
    string S;

    map<string, int> items;
    rep(i, N) {
        cin >> S;
        auto item = items.find(S);
        if(item == items.end() ) {
            items[S] = 1;
        }
    }
    
    cout << items.size() << endl;
    
    return 0;
}

Measured memory_bytes: 19268
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();
            if (n == 0 && x == 0) {
                break;
            }
            int ans = 0;
            for (int i = 1; i <= n; i++) {
                for (int j = i + 1; j <= n; j++) {
                    int need = x - (i + j);
                    if (need <= n && need > i && need != j) {
                        ans++;
                    }
                }
            }
            System.out.println(ans / 2);
        }
    }
}


Measured memory_bytes: 26264
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  int m=max({A,B,C});
  int n=m;
  for(int i=0;i<K;i++){
    n *= 2;
  }
  cout<<A+B+C-m+n<<endl;
}

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

vector<int> sieve(int v)
{
	vector<int> p(v + 1, 0);
	p[0] = -1;
	p[1] = -1;

	int sqrt_v = ceil(sqrt(v));
	for (int i = 2; i <= sqrt_v; ++i)
	{
		if (p[i]) continue;

		for (int j = i * i; j <= v; j += i)
		{
			if(!p[j]) p[j] = i;
		}
	}

	return p;
}

long long modinv(long long a, long long m) {
	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;
}

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

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

	auto p = sieve(1e6);

	map<int, int> m;
	for (int i = 0; i < n; ++i)
	{
		map<int, int> m2;
		int rest = a[i];
		while (rest > 1)
		{
			if (p[rest])
			{
				++m2[p[rest]];
				rest /= p[rest];
			}
			else
			{
				++m2[rest];
				rest /= rest;
			}
		}
		for (auto pair : m2)
		{
			m[pair.first] = max(m[pair.first], pair.second);
		}
	}

	unsigned long long lcm = 1;
	for (auto pair : m)
	{
		lcm = lcm * pow(pair.first, pair.second);
		lcm %= 1000000007;
	}

	ll ans = 0;
	for (int i = 0; i < n; ++i)
	{
		ans += lcm * modinv(a[i], 1000000007);
		ans %= 1000000007;
	}

	cout << ans % 1000000007;

}


Measured memory_bytes: 4608
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int cost = 0;
	if (a + b > c*2) {
		int Min = min(x, y);
		cost += Min *c*2;
		x -= Min  ;
		y -= Min  ;
		//cout << cost << endl;
		if (x == 0) {
			int co = min(b, c * 2);
			cost += co * y;
		}
		else if (y == 0) {
			int co = min(a, c * 2);
			cost += co * x;
		}
		else if (x == 1) {
			int co = min(a + b, c * 2);
			int co1 = min(b, c * 2);
			cost += co + co1 * (y - 1);
		}
		else if (y == 1) {
			int co = min(a + b, c * 2);
			int co1 = min(a, c * 2);
			cost += co + co1 * (x - 1);
		}
	}
	else {
		cost = a * x + b * y;
	}
	cout << cost << endl;
}

Measured memory_bytes: 256
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr ll inf = INT32_MAX / 2;
constexpr ll INF = LLONG_MAX / 2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }

    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int A, B;
    cin >> A >> B;
    if (B % A == 0) {
        cout << A + B << endl;
    }
    else {
        cout << B - A << endl;
    }
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
long long n,W;
long long w,v;
long long dp[110][100010];
int main()
{
	cin>>n>>W;
	for(int i=0;i<n;i++){
		cin>>w>>v;
		for(int j=0;j<=W;j++){
			if(dp[i][j]!=-1){
				dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
				if(j+w<=W){
					dp[i+1][j+w]=max(dp[i+1][j+w],dp[i][j]+v);
				}
			}
		}
	}
	cout<<*(max_element(dp[n],dp[n]+W+1));
	return 0;
}


Measured memory_bytes: 79360
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

def abc077_c():
    ''' maspyさんお手本 '''
    N = int(readline())
    A = np.array(readline().split(), dtype=np.int64)
    B = np.array(readline().split(), dtype=np.int64)
    C = np.array(readline().split(), dtype=np.int64)

    A.sort()
    B.sort()
    C.sort()

    # 各Bに対して使えるAの個数
    cnt_A = np.searchsorted(A, B, side='left')
    # 各Bに対して使えないCの個数
    cnt_C_not = np.searchsorted(C, B, side='right')
    # 各Bに対して使えるCの個数
    cnt_C = N - cnt_C_not
    # 別の書き方
    # cnt_C_alt = np.searchsorted(-1 * np.flip(C), -1 * B, side='left')

    ans = np.multiply(cnt_A, cnt_C).sum()
    print(ans)

abc077_c()

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


int selectionSort(int A[], int n){
	int mini, count = 0;
	for( int i = 0; i < n - 1; i++) {
		mini = i;
		//search  a mini element position
		for ( int j = i; j < n; j++) {
			if (A[j] < A[mini]) {
				mini = j;
			}
		}
		swap(A[i], A[mini]);
		if(i != mini ) count++;
	}
	return count;
}

int main() {
	int n, A[100];
	cin >> n;

	for (int i = 0; i < n; i++) cin >> A[i];

	int c = selectionSort(A, n);
	for (int i = 0; i < n; i++) {
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << c << endl;
	return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int na, nb, ma, mb, nc, a[N], b[N], c[N], d[2*N];
int main(){
	// freopen("input.txt", "r", sstdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin>>ma>>mb>>na>>nb>>nc;
	for (int i=1; i<=na; i++){
		cin>>a[i];
	}
	for (int i=1; i<=nb; i++){
		cin>>b[i];
	}
	for (int i=1; i<=nc; i++){
		cin>>c[i];
	}
	a[na+1] = 2e9;
	b[nb+1] = 2e9;
	c[nc+1] = 2e9;
	sort(a+1, a+na+1);
	sort(b+1, b+nb+1);
	sort(c+1, c+nc+1);
	int posa = na - ma + 1;
	int posb = nb - mb + 1;
	int posc = 1;
	long long ans = 0;
	for (int i=1; i<=ma+mb+nc; i++){
		if (a[posa] >= c[posc] && b[posb] >= c[posc]){
			d[i] = c[posc];
			posc++;
		}
		else if (a[posa] >= b[posb] && c[posc] >= b[posb]){
			d[i] = b[posb];
			posb++;
		}
		else{
			d[i] = a[posa];
			posa++;
		}
		if (i > nc){
			ans = ans + d[i];
		}
	}
	cout<<ans;
}

Measured memory_bytes: 2176
#include <iostream>
#include <sstream>
#include <iterator>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <numeric>

#define YESNO(x) x ? printf("YES") : printf("NO")
#define YesNo(x) x ? printf("Yes") : printf("No")
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define scani(x) scanf("%d", &x)
#define scanll(x) scanf("%lld", &x)
#define printi(x) printf("%d", x)
#define printll(x) printf("%lld", x)
typedef long long ll;
using namespace std;

long long GCD(long long x, long long y) {
	return y ? GCD(y, x % y) : x;
}

long long LCM(long long x, long long y) {
	return x * y / GCD(x, y);
}

int Main() {
	int n;

	scani(n);

	YesNo(7 == n % 10 || 7 == n / 10 % 10 || 7 == n / 100);


	return 0;
}

//int Main() {
//	int n;
//
//	scani(n);
//
//	int ans = 0;
//	for (int i = 1; i <= n; i++) {
//		if (i % 3 && i % 5) {
//			ans += i;
//		}
//	}
//
//	printi(ans);
//
//	return 0;
//}

int main()
{
	Main();
	return 0;
}


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

typedef long long ll;

/* メモリ食い過ぎ注意 */
#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

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

    int dp[100001] = {};
    set<int> s;
    s.insert(1);
    for (int i = 1; pow(6, i) <= 1e5; i++)
        s.insert(pow(6, i));
    for (int i = 1; pow(9, i) <= 1e5; i++)
        s.insert(pow(9, i));

    for (int i = 1; i <= 1e5; i++)
        dp[i] = INF;

    for (auto itr = s.begin(); itr != s.end(); itr++)
    {
        for (int i = 1; i <= n; i++)
        {
            if (i - *itr >= 0)
            {
                dp[i] = min(dp[i], min(dp[i - 1] + 1, dp[i - *itr] + 1));
            }
            else
            {
                dp[i] = min(dp[i], dp[i - 1] + 1);
            }
        }
        // cout << *itr << ":" << endl;
        // for (int i = 0; i <= n; i++)
        // cout << dp[i] << " ";
        // cout << endl;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1280
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
lst = []
for _ in range(K):
    d = int(readline())
    lst += list(map(int, readline().split()))

x = N - len(set(lst))
print(x)

Measured memory_bytes: 9256
for i in range(10000):
  x = input().split()
  h = int(x[0])
  w = int(x[1])
  if h == 0 and w == 0:
    break
    
  if h % 2 == 0:
    
    if w % 2 == 0:
      for i in range(h//2):
        for i in range(w//2):
          print("#",end="")
          print(".",end="")
        print()
        for i in range(w//2):
          print(".",end="")
          print("#",end="")
        print()
      print()
      
    elif w % 2 == 1:
      for i in range(h//2):
        for i in range((w-1)//2):
          print("#",end="")
          print(".",end="")
        print("#",end="")  
        print()
        for i in range((w-1)//2):
          print(".",end="")
          print("#",end="")
        print(".",end="")  
        print()  
      print()
      
  
  elif h % 2 == 1:
    
    if w % 2 == 0:
      for i in range((h-1)//2):
        for i in range(w//2):
          print("#",end="")
          print(".",end="")
        print()
        for i in range(w//2):
          print(".",end="")
          print("#",end="")
        print()
      for i in range(w//2):
        print("#",end="")
        print(".",end="")
      print()
      print()
      
    elif w % 2 == 1:
      for i in range((h-1)//2):
        for i in range((w-1)//2):
          print("#",end="")
          print(".",end="")
        print("#",end="")  
        print()
        for i in range((w-1)//2):
          print(".",end="")
          print("#",end="")
        print(".",end="")  
        print()  
      for i in range((w-1)//2):
        print("#",end="")
        print(".",end="")
      print("#",end="")  
      print()
      print()
          


Measured memory_bytes: 7020
#include <stdio.h>
#include <algorithm>

#define BUF 200002
#define LIM_N 10002

char str[BUF];

int N, K;
char S[LIM_N];

int left;
int right;

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%s", &S);
}

void initialize() {
	left = (S[0] - '0') * 10 + (S[1] - '0');
	right = (S[2] - '0') * 10 + (S[3] - '0');
}

int isYYMM() {
	if (1 <= right && right <= 12) {
		return 1;
	}
	return 0;
}

int isMMYY() {
	if (1 <= left && left <= 12) {
		return 1;
	}
	return 0;
}

int main(void) {
	receive_input();
	initialize();

	if (isYYMM() && isMMYY()) {
		printf("AMBIGUOUS\n");
	} else if (isYYMM()) {
		printf("YYMM\n");
	} else if (isMMYY()) {
		printf("MMYY\n");
	} else {
		printf("NA\n");
	}

	return 0;
}


Measured memory_bytes: 128
import kotlin.math.min

// TODO: ←消す

fun main() = ABC168C.main()

object ABC168C {
    fun log(message: Any?) {
        println(message)// TODO: ←消す
    }

    fun main() {
        val (A, B, H, M) = readInts()

        val hourArg = Math.PI * 2 * H / 12 + Math.PI /6 * M / 60
        val minuteArg = Math.PI * 2 * M / 60
        val d = Math.abs(hourArg - minuteArg) // 0~2pi

        val arg = min(d, 2 * Math.PI - d)   // 0~pi

        val a = A.toDouble()
        val b = B.toDouble()
        val ans = Math.sqrt((a * a) + (b * b) - (a * b * Math.cos(arg) * 2))

        println(ans)
    }


    /*####################################################################################*/

    fun readString() = readLine()!!
    fun readStrings() = readLine()!!.split(" ")
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }
    fun readLong() = readLine()!!.toLong()
    fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
    fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }

    fun Boolean.yesOrNo() = if (this) "Yes" else "No"
    fun Double.toNaturalExpr() = println("%f".format(this))
}

Measured memory_bytes: 36644
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion

int main()
{
	int n; cin >> n;
	vector<ll> a(n); rep(i, n)cin >> a[i];
	vector<ll> res(n);
	rep(i, n - 1)
	{
		res[i + 1] = a[i] - res[i];
	}
	ll d = (a.back() - res.back()) / 2;
	rep(i, n)
	{
		if (i % 2 == 0)cout << (res[i] + d)*2 << " ";
		else cout << (res[i] - d)*2 << " ";
	}
}

Measured memory_bytes: 4832
n, m = map(int, input().split())

student = [[0, 0]] * n
checkpoint = [[0, 0]] * m
#data input 
for i in range(n) :
    student[i] = list(map(int, input().split()))
    
for i in range(m) :
    checkpoint[i] = list(map(int, input().split()))
# processing

for i in range(n) :
    distancelist = []
    for j in range(m) :
        distancelist += [abs(student[i][0]-checkpoint[j][0]) + abs(student[i][1]-checkpoint[j][1])]
        closestdistance = min(distancelist)
        closestcheckpoint = distancelist.index(closestdistance) + 1
    print(closestcheckpoint)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long n;
string solve(long long v){
	string ans="";
	while(v){
		int a=v%(long long)26;
		if(a==0)a=25;
		else a--;
		ans=(char)(a+'a')+ans;
		if(v%26)v/=26;
		else v=v/26-1;
	}
	return ans;
}
int main(){
	cin>>n;
	cout<<solve(n);
	return 0;
}

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

int main(){
	int x,y;
	cin >> x>>y;
//    cout << x*y << endl;
	if(x>y){
		cout << "a > b" << endl;
	}
	else if(x<y){
		cout << "a < b" << endl;
	}else{
		cout << "a == b" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int s;
  cin >> s;
  
  int a[3] = {};
  a[0] = s;
  int count = 4;
  int flag = 0;
  
  if (a[0] == 1 || a[0] == 2) {
    flag = 1;
  }
    
  while (flag == 0) {
    for (int i = 0; i < 3; i++) {
      if(a[i] % 2 == 0) {
        a[i + 1] = a[i] / 2;
      } else {
        a[i + 1] = 3 * a[i] + 1;
      }
    }
    
    if (a[0] == 4) {
      flag = 1;
    } else {
      a[0] = a[1];
      count += 1;
    }
  }
  
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
//file_name:ABC87_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int a,b,c,x;
    scanf("%d%d%d%d",&a,&b,&c,&x);


    ll ans = 0;

    rep(i,a+1){
        rep(j,b+1){
            rep(k,c+1){
                if(i*500+j*100+k*50==x){
                    ans++;
                }
            }
        }
    }

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



Measured memory_bytes: 256
import sys

f_i = sys.stdin

V, E = map(int, f_i.readline().split())

# adjacency matrix
no_edge = 14001

adj = [[no_edge] * V for i in range(V)]

for i in range(V):
    adj[i][i] = 0

odd_b = 0 # bit DP to record odd vertex

ans = 0

# acceptance of input
for l_i in f_i:
    s, t, d = map(int, l_i.split())
    t_d = min(d, adj[s][t])
    adj[s][t] = t_d
    adj[t][s] = t_d
    odd_b ^= 1 << s
    odd_b ^= 1 << t
    ans += d

# A function to check if the number of 1 in binary notation is odd
def odd_one(n):
    ans = 0
    while n:
        ans ^= (n & 1)
        n >>= 1
    return ans

import math

if odd_b:
    # Warshall???Floyd Algorithm
    for k in range(V):
        for i in range(V):
            for j in range(V):
                adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j])
                
    # Minimum weighted matching
    mw = [no_edge] * (odd_b + 1)
    mw[0] = 0
    digits = int(math.log2(odd_b)) + 1

    for b, mw_b in enumerate(mw):
        if odd_one(b):
            continue
        for i in range(0, digits):
            if b & (1 << i):
                continue
            for j in range(i + 1, digits):
                if b & (1 << j):
                    continue
                t_b = b + (1 << i) + (1 << j)
                if t_b == t_b & odd_b:
                    t_w = mw[t_b]
                    mw[t_b] = min(t_w, mw_b + adj[i][j])

    # Output
    ans += mw[odd_b]
    print(ans)
else:
    print(ans)

Measured memory_bytes: 7988
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#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 <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 <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  string s;
  cin >> s;
  int64_t res = 0, cnt = 0;
  rep(i,s.size()) {
    if(s[i] == 'B') cnt++;
    else res += cnt;
  }

  cout << res << endl;
  return 0;
}

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

int main(){
  int n,m;
  bool f[500][500];
  bool ans[500];
  int a,b;

  for(;;){
    cin >> n >> m;
    if(!n && !m)break;

    for(int i=0;i<n;i++){
      ans[i] = false;
      for(int j=0;j<n;j++)f[i][j] = false;
    }

    while(m--){
      cin >> a >> b;
      a--;
      b--;
      f[a][b] = true;
      f[b][a] = true;
      if(!a)ans[b] = true;
      if(!b)ans[a] = true;
    }

    for(int i=0;i<n;i++)
      if(f[0][i])
	for(int j=0;j<n;j++)ans[j] |= f[i][j];

    cout << count(ans+1,ans+n,true) << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

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

    priority_queue<int> pq;
    for (int i = 0; i < N; ++i){
        int a;
        cin >> a;
        pq.push(a);
    }

    for (int i = 0; i < M; ++i)
    {
        int a = pq.top();
        pq.pop();
        a = a / 2;
        pq.push(a);
    }
    long int ans = 0;
    for (int i = 0; i < N; ++i)
    {
        int a = pq.top();
        pq.pop();
        ans += a;
    }

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

Measured memory_bytes: 892
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var h = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int ans = 0;
            int startIndex = 0, endIndex = 0;
            while (h.Any(x => x != 0))
            {
                endIndex = 0;
                while (endIndex != N)
                {
                    startIndex = endIndex;
                    while (startIndex < N && h[startIndex] == 0)
                    {
                        startIndex++;
                    }
                    if (startIndex == N)
                    {
                        break;
                    }

                    endIndex = startIndex + 1;
                    while (endIndex < N && h[endIndex] != 0)
                    {
                        endIndex++;
                    }

                    for (int i = startIndex; i < endIndex; i++)
                    {
                        h[i]--;
                    }
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}



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

int main()
{
    std::string s;
    std::cin >> s;

    std::sort(s.begin(), s.end());

    if (s == "abc") {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f(i, a, n) for (int i = a; i < n; i++)
#define f1(i, a, n) for (int i = n; i >= a; i--)
#define pb push_back
#define mp make_pair
#define ins insert
#define ers erase
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvpii vector<vpii>
#define vbl vector<bool>
#define upb upper_bound
#define lwb lower_bound
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define umap unordered_map
#define uset unordered_set
#define gcd __gcd
const ll MOD = 1e9 + 7;
#define INF INT_MAX
using namespace std;

ll n;
string str;

bool check(int low, int high)
{
    bool res = true;
    int i = low, j = high;
    while(i <= j)
    {
        if(str[i] != str[j])
        return false;
        i ++;
        j --;
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cin.tie(NULL);
    cout.tie(NULL);
    
    cin >> str;
    int n = str.size();
    bool ans = (check(0,n-1) & check(0,(n-1)/2 - 1) & check((n+1)/2, n-1));
    if(ans) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define int ll
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x
void prep()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}
int32_t main()
{
	prep();
	int a,b,h,m;
	cin>>a>>b>>h>>m;
	double hour_angle = 0.5 * (h * 60 + m);  

    double minute_angle = 6.0 * m; 
    double angle = abs(hour_angle - minute_angle);  
    angle = min(360 - angle,angle);
    angle=angle*3.14159265358979323846/180;
    double ans=sqrt(a*a+b*b-2*a*b*cos(angle));
    cout<<ps(ans,11);
    
	return 0;
}



Measured memory_bytes: 4244
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};

int main(){
    int INF = 1e6;
    int H,W; cin >> H >> W;
    char A[1010][1010];
    int ans[H][W];
    queue<pair<int,int>> que;

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            ans[i][j] = INF;
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> A[i][j];
            if(A[i][j] == '#'){
                que.push(pair<int,int> (i,j));
                ans[i][j] = 0;
            }
        }
    }

    


    while(que.size()){
        pair<int,int> p = que.front(); que.pop();
        for(int k=0;k<4;k++){
            int ny = p.first + my4[k];
            int nx = p.second + mx4[k];
            if(A[ny][nx] == '.' && ans[p.first][p.second] + 1 < ans[ny][nx]){
                ans[ny][nx] = ans[p.first][p.second] + 1;
                que.push(pair<int,int> (ny,nx));
                
            }
        }
    }
    int ANS = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            ANS = max(ANS,ans[i][j]);
        }
    }

    cout << ANS << endl;
}

Measured memory_bytes: 13328
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    string S;
    cin >> S;
    for( int i = 0; i < (int)S.size() + 1; i++ )
    {
        if( S[ i ] == 'A' && S[ i + 1 ] == 'C' )
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

#define re register
#define gc getchar()
#define ll long long

inline ll read() {
	re ll x(0), f(1); re char c(gc);
	while (c > '9' || c < '0') f = c == '-' ? -1 : 1, c = gc;
	while (c <= '9' && c >= '0') x = x * 10 + c -48, c = gc;
	return x * f;
}

const int N = 3030, mod = 1e9 + 7;
int n, q, a[N];
ll ans, f[N][N], inv;

ll qpow (ll a, int b) {
    ll x (1);
    while (b) {
        if (b & 1) x = x * a % mod;
        a = a * a % mod, b >>= 1;
    } return x;
}

int main () {
    n = read(), q = read();
    for (int i = 1; i <= n; ++i)
        a[i] = read();
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <=n; ++j) 
            f[i][j] = a[i] < a[j];
    inv = qpow (2, mod -2);
    for (int d = 1; d <= q; ++d) {
        int x = read(), y = read();
        f[x][y] = f[y][x] = inv * (f[x][y] + f[y][x]) % mod;
        for (int j = 1; j <= n; ++j) if (j != x && j != y) {
            f[j][x] = f[j][y] = inv * (f[j][x] + f[j][y]) % mod;
            f[x][j] = f[y][j] = inv * (f[x][j] + f[y][j]) % mod;
        }
    } ll ans = 0;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <i; ++j)
            ans = (ans + f[i][j]) % mod;
    cout << ans * qpow (2, q) % mod << '\n';
    return 0;
}

Measured memory_bytes: 71936
S = input()
if len(S) % 2 == 0:
    T = "10"*(len(S)//2)
    U = "01"*(len(S)//2)
else:
    T = "10"*(len(S)//2)+"1"
    U = "01"*(len(S)//2)+"0"

ans1,ans2 = 0,0
for i in range(len(S)):
    if S[i] != T[i]:
        ans1 += 1
    if S[i] != U[i]:
        ans2 += 1
print(min(ans1,ans2))

Measured memory_bytes: 3316
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        System.out.println(lcm(a,b));
    }

    private static long lcm(long a, long b)
    {
        return a * (b / gcd(a, b));
    }

    private static long gcd(long a, long b)
    {
        while (b > 0)
        {
            long temp = b;
            b = a % b; // % is remainder
            a = temp;
        }
        return a;
    }

}



Measured memory_bytes: 23632