akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

std::vector<int> A(110);

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

    int a_score = 0;
    int b_score = 0;
    bool a_turn = true;

    while(!A.empty()) {
        std::vector<int>::iterator maxItr = std::max_element(A.begin(), A.end());
        if (a_turn) {
            a_score += *maxItr;
            a_turn = false;
        } else {
            b_score += *maxItr;
            a_turn = true;
        }
        A.erase(maxItr);
    }
    cout << (a_score - b_score) << endl;
}



Measured memory_bytes: 256
from collections import deque
N = int(input())
graph = [list(map(int, input().split())) for _ in range(N)]
seen = [-1]*(N+1)

todo = deque()


def bfs(v):
    u = v-1
    next_v = graph[u][2:]
    for i in next_v:
        if seen[i] == -1:
            seen[i] = seen[v] + 1
            todo.append(i)


todo.append(1)
seen[1] = 0

while len(todo) > 0:
    bfs(todo.popleft())

for i in range(1, N+1):
    print(i, seen[i])


Measured memory_bytes: 6032
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if(A < B):
  oni = A + V*T
  chi = B + W*T
  if(oni>=chi):
    print('YES')
  else:
    print('NO')
else:
  oni = B + V*T
  chi = A + W*T
  if(oni>=chi):
    print('YES')
  else:
    print('NO')

Measured memory_bytes: 61608
if __name__ == '__main__':
    scaffold_count = int(input())
    scaffold_list = list(map(int, input().split()))
    jump_costs = [0] * scaffold_count
    jump_costs[0] = 0
    jump_costs[1] = abs(scaffold_list[0] - scaffold_list[1])
    for i in range(2, scaffold_count):
        jump_costs[i] = min(jump_costs[i - 2] + abs(scaffold_list[i - 2] - scaffold_list[i]),
                            jump_costs[i - 1] + abs(scaffold_list[i - 1] - scaffold_list[i]))
    print(jump_costs[scaffold_count - 1])

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

int main() {
  int N;
  cin >> N;
  
  vector<long long>a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  int count = 0;
  for (int i = 0; i < N; i++) {
    while(a.at(i) % 2 == 0){
      a.at(i) /= 2;
      count++;
    }
  }
  cout << count << endl;
}
  

  
 



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

using namespace std;

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

  string s;
  cin >> s;
  if (s[0] == s[1] and s[1] == s[2] and s[2] == 'R') cout << 3;
  else if ((s[0] == s[1] or s[1] == s[2]) and s[1] == 'R') cout << 2;
  else if (s[0] == 'R' or s[1] == 'R' or s[2] == 'R') cout << 1;
  else cout << 0;

  return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
//typedef __int64 LL;
typedef long long int LL;

typedef vector<int> ivec;
typedef vector<string> svec;

LL a[200010];
int main(){
	int n=0;
	LL ans=10000000000000000;
	LL sum=0;
	cin>>n;	
	for(int i=0;i<n;i++)
	{
		LL x=0;
		cin>>x;
		sum+=x;
		a[i]=sum;
	}
	
	for(int i=0;i<n-1;i++)
	{
		LL y=sum-2*a[i];
		if(y<0)y*=-1;
		//ans=min(ans,x);
		if(ans>y)ans=y;
	}
	
    
	cout<<ans<<endl;
	return 0;
}

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

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

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
 
const ll MAX = 1e6 + 3;
const ll inf = 1e18;
const ll mod = 1e6 + 3;



int main(){
    fastio;
    ll n;
    cin >> n;
    cout << n*n << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N, K, Q; cin >> N >> K >> Q;
  vector<int> A(N, 0);
  for (int i = 0; i < Q; ++i) {
    int a; cin >> a; --a;
    A[a]++;
  }
  for (int i = 0; i < N; ++i) {
    int score = K + A[i] - Q;
    if (score > 0) cout << "Yes" << endl;
    else           cout << "No" << endl;
  }
}


Measured memory_bytes: 3784
s = input()

ans = 1
t = s[0]
i = 1

while i < len(s)-1:
    if len(t) == 2:
        t = s[i]
        i += 1
    elif t == s[i]:
        t = s[i:i+2]
        i += 2
    else:
        t = s[i]
        i += 1
    ans += 1

if i == len(s)-1 and t != s[-1]:
    print(ans + 1)
else:
    print(ans)

Measured memory_bytes: 9288
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

struct Point {
    double x, y;
};

const double eps = 1e-9;
const int N = 55, K = 1e3 + 10, steps = 100, inf = 1e3 + 10;
int n;
Point a[N];

double dist(Point A, Point B) {
    return sqrt((A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y));
}

double radius(Point O) {
    double R = 0;
    for (int i=1; i<=n; i++) {
        R = max(R, dist(O, a[i]));
    }
    return R;
}

double y_radius(double x) {
    double ly = -inf, ry = inf;
    for (int sy=1; sy<=steps; sy++) {
        double diff = (ry - ly) / 3;
        double y1 = ly + diff, y2 = ry - diff;
        double f1 = radius({x, y1}), f2 = radius({x, y2});
        if (f1 > f2) {
            ly = y1;
        }
        else {
            ry = y2;
        }
    }
    return radius({x, ly});
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    cout << fixed << setprecision(12);
    cin >> n;
    for (int i=1; i<=n; i++) {
        cin >> a[i].x >> a[i].y;
    }
    double lx = -inf, rx = inf;
    for (int sx=1; sx<=steps; sx++) {
        double diff = (rx - lx) / 3;
        double x1 = lx + diff, x2 = rx - diff;
        double f1 = y_radius(x1), f2 = y_radius(x2);
        if (f1 > f2) {
            lx = x1;
        }
        else {
            rx = x2;
        }
    }
    cout << y_radius(lx) << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

using namespace std;

int main(){
    string s;
    cin >> s;
    
    stack<char> st;
    int n = s.size();
    
    for (int i = 0; i < n; i++){
        
        if (s[i] == 'B'){
            if (st.empty()) continue;
            else st.pop();
        }
        else{
            st.push(s[i]);
        }
    }
    
    string ans = "";
    while (!st.empty()){
        char temp = st.top();
        st.pop();
        ans = temp + ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3532
Q, H, S, D = map(int, input().split())
N = int(input())

if N == 1:
    ans = min(Q*4, H*2, S)
else:
    n = N // 2
    ans = min(Q*8, H*4, S*2, D)
    ans *= n
    if N % 2 == 1:
        ans += min(Q*4, H*2, S)

print(ans)

Measured memory_bytes: 9128
#include <iostream>

using namespace std;

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  int ow = 0, oh = 0;
  int x[110] = {0};
  int y[110] = {0};
  int a[110] = {0};
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    cin >> y[i];
    cin >> a[i];
  }

  for (int i = 0; i < n; i++) {
    switch (a[i]) {
    case 1:
      if (ow < x[i]) {
        ow = x[i];
      }
      break;
    case 2:
      if (x[i] < w) {
        w = x[i];
      }
      break;
    case 3:
      if (oh < y[i]) {
        oh = y[i];
      }
      break;
    case 4:
      if (y[i] < h) {
        h = y[i];
      }
      break;
    }
  }
  int ans = 0;
  if (w > ow && h > oh) {
    ans = (w - ow) * (h - oh);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3160
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	for i := n - 1; 0 <= i; i-- {
		if i != n-1 {
			fmt.Print(" ")
		}
		fmt.Print(a[i])
	}
	fmt.Println()
}



Measured memory_bytes: 1132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
void read(int& x){ scanf("%d",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back

int stone[100010];

vector<int> ed[100010];

int par[100010];

void NO(){ puts("NO"); exit(0); }

int dfs(int x){
	if(ed[x].size() == 1u) return stone[x];
	multiset<int> ss;
	ll paths=0;
	for(int y:ed[x]) if(par[x]!=y){
		par[y]=x;
		ll tmp=dfs(y);
		ss.insert(tmp);
		paths += tmp;
	}
	ll pairs = paths-stone[x];
	if(pairs < 0) NO();
	if(paths - 2*pairs < 0) NO();
	ll mm = 0, Mv=*--ss.end();
	mm = min(paths/2, paths-Mv);
	if(mm < pairs) NO();
	return paths - 2*pairs;
}

int main()
{
    int n;
    read(n);
    for(int i=1; i<=n; ++i) read(stone[i]);
    for(int i=1; i<n; ++i){
		int a, b; read(a, b);
		ed[a].pb(b); ed[b].pb(a);
    }
    
    if(n == 2){
		if(stone[1] == stone[2]) puts("YES");
		else puts("NO");
		return 0;
    }
    
    int root=1;
    while(ed[root].size() == 1u) ++root;
    
    if(dfs(root)) NO();
    puts("YES");
    return 0;
}


Measured memory_bytes: 18560
import java.util.Scanner;

class Main{

    public static void main(String[] args) {
        // write your code here

        Scanner sc = new Scanner(System.in);

        int h = sc.nextInt();
        int a = sc.nextInt();

        if(h%a==0)
            System.out.println(h/a);
        else
            System.out.println((h/a)+1);
    }
}


Measured memory_bytes: 21844
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  using P = tuple<ll, ll, ll>;
  vector<P> vec(n);
  for(int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    vec[i] = make_tuple(a + b, a, b);
  }
  sort(begin(vec), end(vec));

  ll ans = 0;
  for(int i = n - 1; i >= 0; i--) {
    ll x; ll y;
    tie(ignore, x, y) = vec[i];
    ans += x;
    i--;
    if(i < 0) break;
    tie(ignore, x, y) = vec[i];
    ans -= y;
  }

  cout << ans << endl;

  return 0;
}


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

string join(const vector<int> &arr) {
  string result = "";
  result += to_string(arr[0]);
  for (int i = 1; i < arr.size(); i++) {
    result += (" " + to_string(arr[i]));
  }
  return result;
}

int main(void) {
  int n;
  cin >> n;
  vector<int> as(n);
  for (int i = 0; i < n; i++) {
    int idx = n / 2 + ((n + i) % 2 == 1 ? -1 : 1) * ((i + 1) / 2);
    cin >> as[idx];
  }

  cout << join(as) << endl;
  return 0;
}

Measured memory_bytes: 4996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<vector<int>> A(3,vector<int>(3)),ok(3,vector<int>(3,0));
    rep(i,3) rep(j,3) cin >> A[i][j];
    int N; cin >> N;
    rep(_,N){
        int b; cin >> b;
        rep (i,3) rep(j,3) if (A[i][j]==b) ok[i][j]=1;
    }
    int bingo=0;
    rep(i,3){
        rep(j,3){
            if (!ok[i][j]) break;
            if (j==2) bingo=1;
        }
        rep(j,3){
            if (!ok[j][i]) break;
            if (j==2) bingo=1;
        }
    }
    rep(i,3){
        if (!ok[i][i]) break;
        if (i==2) bingo=1;
    }
    rep(i,3){
        if (!ok[i][2-i]) break;
        if (i==2) bingo=1;
    }
    cout << (bingo?"Yes":"No") << '\n';
}

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

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

  int A, B; cin >> A >> B;
  string S; cin >> S;
  
  bool flag = true;
  for (int i = 0; i < S.size(); i++) {
    if (i != A && S[i] == '-') flag = false;
    else if (i == A && S[i] != '-') flag = false;
  }
  cout << (flag ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 string s,t;
  cin>>s>>t;
  s+=s;
  bool ans=false;
  int n=s.size();
  rep(i,0,n/2){
    bool ok=true;
    rep(j,0,n/2){
        if(s[i+j]==t[j]){}
          else ok=false;
      }
    
    
    if(ok) {
     ans=true; 
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<map>

using namespace std;

int main(void) {
	map<char, char> chgMap;
	int num;
	char in1, in2;
	int i;

	while(true) {
		cin >> num;
		if(num == 0) { break; }
		chgMap.clear();
		for(i = 0; i < num; i++) {
			cin >> in1 >> in2;
			chgMap[in1] = in2;
		}
		cin >> num;
		for(i = 0; i < num; i++) {
			cin >> in1;
			if(chgMap.find(in1) != chgMap.end()) { cout << chgMap[in1]; }
			else { cout << in1; }
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 904
sx, sy, gx, gy = map(int, input().split(' '))

route = []
dy = gy - sy
dx = gx - sx
route.append('U' * dy)
route.append('R' * dx)
route.append('D' * dy)
route.append('L' * (dx + 1))
route.append('U' * (dy + 1))
route.append('R' * (dx + 1))
route.append('DR')
route.append('D' * (dy + 1))
route.append('L' * (dx + 1))
route.append('U')
print(''.join(route))


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

using namespace std;

int main(){

     int N;
     cin >> N;
     int cnt=0;
    vector <int> vec(N);

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

   for(int k=0;k<N;k++){

       if (vec[k]==vec[k+1]){
           cnt++;
           vec[k+1]+=100;
       }
   }
   cout << cnt <<endl;
}

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

int calc(int ax, int ay, int bx, int by){
  if(ax * bx + ay * by == 0){
    return 1;
  }

  if(ax * by - ay * bx == 0){
    return 2;
  }

  return 0;
}

int main(){
  int q, i, xp0, xp1, xp2, xp3, yp0, yp1, yp2, yp3;
  cin >> q;
  int A[q];

  for(i = 0; i < q; i++){
    cin >> xp0 >> yp0 >> xp1 >> yp1 >> xp2 >> yp2 >> xp3 >> yp3;
    A[i] = calc(xp1-xp0,yp1-yp0, xp3-xp2, yp3-yp2);
  }

  for(i = 0; i < q; i++){
    cout << A[i] << endl;
  }

}


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

int main()
{
	for (int t = 0; t < 3; t++) {
		int h, m, s, tmp;
		cin >> h >> m >> s;
		cin >> tmp; h = tmp - h;
		cin >> tmp; m = tmp - m;
		cin >> tmp; s = tmp - s;
		if (s < 0) s += 60, m--;
		if (m < 0) m += 60, h--;
		cout << h << ' ' << m << ' ' << s << endl;
	}
	return 0;
}



Measured memory_bytes: 3088
n = int(input())

dp = [float('inf')] * (n + 1)
dp[0] = 0


for i in range(n):
    dp[i + 1] = min(dp[i + 1], dp[i] + 1)
    for j in range(n):
        if i + 6 ** (j + 1) <= n:
            dp[i + 6 ** (j + 1)] = min(dp[i + 6 ** (j + 1)], dp[i] + 1)
        else:
            break
    for k in range(n):
        if i + 9 ** (k + 1) <= n:
            dp[i + 9 ** (k + 1)] = min(dp[i + 9 ** (k + 1)], dp[i] + 1)
        else:
            break

print(dp[n])

Measured memory_bytes: 47692
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b)
{
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}

int main(){
 int  N;
  cin >> N;
  ll n = (ll)N;
  ll ans = n*(n-1)/2;
  cout << ans  << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	if (s=="ABC") cout<<"ARC";
	else cout<<"ABC";
	return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner scn=new Scanner(System.in);
        String n=scn.next();
        scn.close();
        int cnt=0;
        String answer="No";
        if(n.charAt(1)==n.charAt(2)&&(n.charAt(0)==n.charAt(1)||n.charAt(3)==n.charAt(1))) answer = "Yes";
        System.out.println(answer);
    }
}

Measured memory_bytes: 21716
from collections import deque
def main():
    n = int(input())
    ab = []
    visit = [-1 for _ in range(n+1)]
    tree = [[] for _ in range(n+1)]
    for i in range(n-1):
        a, b = map(int,input().split())
        ab.append([a, b])
        tree[a].append(b)
        tree[b].append(a)
    visit[1]=0
    q = deque([1])
    while q:
        s = q.pop()
        d = 0
        for i in tree[s]:
            if visit[i]<0:
                d += 1 + (1+d==visit[s])
                visit[i] = d
                q.append(i)
    print(max(visit))
    for a, b in ab:
        print(visit[b])

if __name__=="__main__":
    main()

Measured memory_bytes: 33576
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

std::vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=0; i<=max; ++i) // 0からmaxまで全て調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=i+1; j<=max; ++j) //i+1からmaxまで全て調べる
                if(j%i==0) // iの倍数は
                    IsPrime[j] = false; // 素数ではない
}


int main(){
    ll n,ans=1;
    cin >> n;
    vector<ll> a(n+1);
    sieve(n);
    for(ll i=2;i<=n;i++){
        ll tmp=i;
        ll j=2;
        while(tmp!=1){
            if(IsPrime[j]==true&&tmp%j==0){
                  a[j]++;
                  tmp/=j;
                  j=1;
            }
            j++;
        }
    }
    for(ll i=2;i<=n;i++){
        ans*=(a[i]+1);
        ans=ans%ll(1e9+7);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
  int n;
  map<int, int> mp;
  cin >> n;
  bool contain_one=false;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    mp[a]++;
    if(a==1)contain_one=true;
  }
  if(contain_one){
    if(mp[1]>1){
      cout << 0 << endl;
      return 0;
    }
    cout << 1 << endl;
    return 0;
  }
  int cnt=0;
  for(auto& p: mp){
    if(p.second>1)continue;
    int value=p.first;
    bool is_ok=true;
    for(int i=2;i*i<=value;i++){
      if(value%i==0 && (mp.find(i)!=mp.end() || mp.find(value/i)!=mp.end())){
        is_ok=false;
        break;
      }
    }
    if(is_ok){
      cnt++;
    }
  }
  cout << cnt << endl;
}



Measured memory_bytes: 13000
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int d = scan.nextInt();
        switch (d) {
            case 25: System.out.println("Christmas"); break;
            case 24: System.out.println("Christmas Eve");  break;
            case 23: System.out.println("Christmas Eve Eve"); break;
            case 22: System.out.println("Christmas Eve Eve Eve"); break;
            default:
        }
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(10);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<int,int>; using vp = vector<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
////////////////

void solve(){
  ini(N , M);
  out(N * M);
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> s = a;
    sort(s.rbegin(),s.rend());
    rep(i,n){
        int ans = s[0];
        if (s[0] == a[i]) ans = s[1];
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
import sys
import math
from collections import Counter

N = int(input())
S = input()

MOD = 1000000007

# baba
# a(2), b(2), ab(1), ba(3)

# baab
# a(2), b(2), ab(2), ba(2)

# 1文字の時は分かる、それは単に数えるだけ
# 2文字の時は?
# 'ab' 'a'どれ選ぶ? → その後ろにある'b'は…

# 全部やるなら2^100000、ムリー

# dpいけるか?

# dpを設計しよう
# dp[n] : n文字目まで見た時の答え
# dp[n] = dp[n-1]

# baab
# dp[0] = 1 (b)
# dp[1] = dp[0]((b)のみ選ぶ) + 1(aのみ選ぶ) + dp[0] * 1 (ab)
# それが新しい文字なら?
# dp[n] = dp[n-1](追加で選ばない) + dp[n-1](選ぶ) + 1

# それが見たことある文字なら?
# 1文字単位では増えない
# n文字単位なら、pickする選択肢が増える
# ba (3)
# baa → 3 + 1?
# dp[n] = dp[n] (そのまま) + 最後の文字を使う
# 最後の文字を使うならどうなるか? → それ以外の種類の文字でつくるんだけど大変じゃない????

# baba
# babで5 a, b(2), ab(1) ba(1)
# 最後の文字を使うなら、bをどちらか選ぶ (か、何も選ばない)
# bをpickするか? * どれをpickするか?
# bをpickしない場合(1) + bをpickする場合(どれを選ぶ?)
# (1 + 2)

# abca
# abcで6 a, b, c, ab, ac, bc
# 最後の文字を使うなら、残りのbcの組み合わせ
# bをpickする/しない * cをpickする/しない 4通り?

ans = 1
counter = Counter()
counter[S[0]] += 1

for ch in S[1:]:
    if ch in counter:
        tmp = 1
        for k, cnt in counter.items():
            if k == ch:
                continue

            tmp = (tmp * (1 + cnt)) % MOD

        ans = (ans + tmp) % MOD
        counter[ch] += 1
    else:
        ans = (2 * ans) % MOD
        ans = (ans + 1) % MOD
        counter[ch] += 1

print(ans)



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

string lowerword(string word)
{
	for (int i=0; i<(int)word.size(); i++)
		word[i]=tolower(word[i]);
	return word;
}

int main(void)
{
	string w1,w2;
	cin>>w1;
	w1 = lowerword(w1);

	int count=0;
	while (cin>>w2){
		if (w2=="END_OF_TEXT") break;
		if (lowerword(w2)==w1) count ++;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int inf = 100005;
ll v[inf];
int main() {
  int n;
  cin >> n;
  ll s = 0;
  rep(i,n){
    int a;
    cin >> a;
    v[a]++;
    s += a;
  }
  int q;
  cin >> q;
  rep(_,q){
    int b,c;
    cin >> b >> c;
    s += v[b]*(c-b);
    v[c] += v[b];
    v[b] = 0;
    cout << s << endl;
  }
}

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

#define HAS_TEST_CASE 0

namespace rG{

typedef long long ll;

const int N=5e5;

int n,m,k,a[N+10];
char s[N+10],t[N+10];

inline void main(){
	scanf("%s%s",s+1,t+1);
	n=int(strlen(s+1));
	m=int(strlen(t+1));
	int ans=0x3f3f3f3f;
	for(int i=1;i<=n-m+1;i++){
		int tmp=0;
		for(int j=i,k=1;j<=i+m-1;j++,k++)
			if(s[j]!=t[k])tmp++;
		ans=std::min(ans,tmp);
	}
	printf("%d\n",ans);
}

} // namespace rG

int main(){
#if defined(LOCAL)&&HAS_TEST_CASE
	freopen("tmp.out","w",stdout);
#endif
#if HAS_TEST_CASE
	int T;
	scanf("%d",&T);
	while(T--)rG::main();
#else
	rG::main();
#endif
	return 0;
}


Measured memory_bytes: 3816
#include <stdio.h>

int main(void);

int main(){
  unsigned char s[2] = {};
  unsigned int tmp;
  
  scanf("%c%c%c", &s[0], &s[1], &s[2]);
  tmp = (unsigned int)((s[0]-'0') + (s[1]-'0') + (s[2]-'0'));
  printf("%d\n", tmp);
  
  return 0;
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
typedef string::const_iterator State;

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


int main(void) {

	long long int n, k;
	long long int x[100001];
	long long int point = 0;
	long long int result = LLINF;
	long long int count = 0;
	long long int left = -1;
	long long int right = -1;


	cin >> n >> k;
	FOR(i, 1, n) {
		cin >> x[i];
	}
	
	FOR(i, 1, n) {
		point = 0;
		if (i + k-1 > n) {
			break;
		}
		left = x[i];
		right = x[i + k - 1];

		if (left <= 0 && right <= 0) {
			point = abs(left);
		}
		else if (left >= 0 && right >= 0) {
			point = abs(right);
		}
		else {
			point = min(abs(right) * 2 + abs(left), abs(left) * 2 + abs(right));
		}

		if (point < result) {
			result = point;
		}
		
	}

	cout << result << endl;
	

	return 0;
}

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

int main(){
  int n;
  int p[10100];
  vector<int> primes;
  
  for(int i=0;i<=10000;i++)p[i] = 0;
  for(int i=2;i<=10000;i++){
    bool f = true;
    for(int j=2;j*j<=i;j++){
      if(i%j==0){
	f = false;
	break;
      }
    }
    if(f)primes.push_back(i);
  }

  for(int i=0;i<primes.size();i++){
    int sum = 0;
    for(int j=i;j<primes.size();j++){
      sum += primes[j];
      if(sum>10000)break;
      p[sum]++;
    }
  }

  while(cin >> n,n)cout << p[n] << endl;
}

Measured memory_bytes: 1272
#include<stdio.h>
int main(){
  int n,m,x,y,max=-1000,min=1000,i;
  int xa,ya;
  scanf("%d%d%d%d",&n,&m,&x,&y);
  for(i=0;i<n;i++){
    scanf("%d",&xa);
    if(max<xa)max=xa;
  }
  for(i=0;i<m;i++){
    scanf("%d",&ya);
    if(min>ya)min=ya;
  }
  if(min>max){
    for(i=max+1;i<=min;i++){
      if(x<i && i<=y){
        puts("No War");
        return 0;
      }
    }
  }
  puts("War");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#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())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
//---------------------------------------------------------------------------------------------------
typedef pair<int,int> P;

int main(void){
    // Your code here!
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 1;
    sort(all(a));
    if (a[0] == 0) {
         cout << 0 << endl;
            return 0;
    }
    rep(i,n) {
        if (a[i] > 1000000000000000000/ans) {
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }
    cout << ans << endl;
}


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

int main() {
	int n;

	cin >> n;

	vector<tuple<string, int, int>> rev;

	for (int i = 0; i < n; i++)
	{
		string s;
		int p;
		cin >> s >> p;
		rev.push_back(make_tuple(s, -p, i + 1));
	}

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

	for (int i = 0; i < n; i++)
	{
		cout << get<2>(rev[i]) << endl;
	}
}

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

int main(void){

    int N;

    scanf("%d", &N);

    long long T[N], A[N];

    for(int i = 0; i < N; i++){
        scanf("%lld%lld", &T[i], &A[i]);
    }

    long long l = T[0], r = A[0];

    for(int i = 0; i < N; i++){
        long long t, a;
        if(l % T[i] == 0){
            t = l / T[i];
        }else{
            t = l / T[i] + 1;
        }

        if(r % A[i] == 0){
            a = r / A[i];
        }else{
            a = r / A[i] + 1;
        }

        if(t > a){
            l = T[i] * t, r = A[i] * t;
        }else{
            l = T[i] * a, r = A[i] * a;
        }
    }

    printf("%lld\n", l + r);

    return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main(void)
{
    string s;
    cin >> s;
    map<char, int> mp;
    rep(i, s.size()) mp[s[i]]++;
    bool flag = true;
    for(auto p: mp) {
        if(p.second != 2) flag = false;
    }

    if(flag) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        long n = sc.nextLong();

        long ans = 0;

        for (int i=1; i<=n; i++) {
            for (int j=1; j<=n; j++) {
                for (int k=1; k<=n; k++) {
                    long tmp = gcd(i, j);
                    ans += gcd(tmp, k);
                }
            }
        }

        System.out.println(ans);
    }

    long gcd(long a, long b) {
        long tmp;
        while ((tmp=a%b)!=0) {
            a = b;
            b = tmp;
        }
        return b;
    }

}


Measured memory_bytes: 27280
#include <iostream>

using namespace std;

int main(){

    int A, B, C, K, maiora = 0, maiorb = 0, maiorc = 0, soma = 0;

    cin >> A >> B >> C >> K;

    if(A > B && A > C){
        maiora = A;
    }else if(B > A && B > C){
        maiorb = B;
    }else if(C > A && C > B){
        maiorc = C;
    }else{
        for(int i = 0; i < K; i++){
            A *= 2;
            soma = A + B + C;
        }
    }

    if(maiora){
        for(int i = 0; i < K; i++){
            maiora *= 2;
        }
        soma = maiora + B + C;
    }else if(maiorb){
        for(int i = 0; i < K; i++){
            maiorb *= 2;
        }
        soma = A + maiorb + C;
    }else if(maiorc){
        for(int i = 0; i < K; i++){
            maiorc *= 2;
        }
        soma = A + B + maiorc;
    }

    cout << soma << endl;

    return 0;
}


Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	int x, t;
	cin >> x >> t;
	cout << max(0, x - t) << '\n';
 	return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    //freopen("in.txt","r",stdin);
    int n;
    cin>>n;
    int maxm;
    cin>>maxm;
    unsigned long long int cnt=0;
    for(int i=1;i<n;i++)
    {
        int x;
        cin>>x;
        if(x>=maxm)
        {
            maxm=x;
            continue;
        }
        else 
        {
            cnt+=(maxm-x);
        }
    }
    cout<<cnt<<endl;

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
struct union_find_tree1{
    vector<int> par;//0-indexed
    union_find_tree1(int sz){ //コンストラクタ
        par.resize(sz); //サイズをszに変更
        for(int i=0;i<sz;++i) par[i] = i; //最初は自分が根
    }
    int find(int a){
        while(a!=par[a]){ //親が自分自身の時、自分が根である
            a = par[a];   //そうでないなら自分に親を代入して辿る
        }
        return a;         //引数aの根が計算されたのでそれを返す。
    }
    void unite(int a,int b){
        int root_a = find(a),root_b = find(b);  //aの根,bの根を調べて代入。
        par[root_a] = root_b;       //根aの親をbにする
    }
    bool same(int a,int b){  //aとbが同じ集合なら1,違うなら0
        return find(a)==find(b);
    }
};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,q;
  cin >> n >> q;
  union_find_tree1 uf(n);
  REP(i,q){
    int com,x,y;
    cin >> com >> x >> y;
    if(com==0){
      uf.unite(x,y);
    }else{
      cout << uf.same(x,y) << endl;
    }
  }
}



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

int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i,n) cin >> a[i];
vector<int> b(n);
rep(i,n) cin >> b[i];
vector<int> c(n-1);
rep(i,n-1) cin >> c[i];
rep(i,n) a[i]--;

int ans =0;
rep(i,n){
    ans += b[a[i]];
   }
rep(i,n){
     if(a[i]+1 == a[i+1]){
        ans += c[a[i]];
    }
}
cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

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

  int result = 0;
  if(N >= 105){
    result++;
    if(N >= 135){
      result++;
      if(N>=165){
        result++;
        if(N>=189){
          result++;
          if(N>=195){
            result++;
          }
        }
      }
    }
  }

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int dp[60][60],i,j,a[60],b[60],c[60],d[60],n,k;
for(i=0;i<55;i++){
for(j=0;j<55;j++){
if(j==0){
dp[i][j]=0;
}
else{
dp[i][j]=100000000;
}
}
}
for(i=0;i<=50;i++){
a[i]=100000,b[i]=100000,c[i]=100000;
}
a[2]=380;
for(i=4;i<=50;i=i+2){
a[i]=a[i-2]+380;
if(i%5==0){
k=i/2;
a[i]=k*380*0.8;
}
}
b[3]=550;
for(i=6;i<=50;i=i+3){
b[i]=b[i-3]+550;
if(i%4==0){
k=i/3;
b[i]=k*550*0.85;
}
}
c[5]=850;
for(i=10;i<=50;i=i+5){
c[i]=c[i-5]+850;
if(i%3==0){
k=i/5;
c[i]=k*850*0.88;
}
}
for(i=0;i<=50;i++){
d[i]=a[i];
}
for(i=0;i<=50;i++){
if(b[i]<d[i]){
d[i]=b[i];
}
}
for(i=0;i<=50;i++){
if(c[i]<d[i]){
d[i]=c[i];
}
}
for(i=1;i<=50;i++){
for(j=1;j<=50;j++){
if(j<i){
dp[i][j]=dp[i-1][j];
}
else{
if(dp[i-1][j]<dp[i-1][j-i]+d[i]){
dp[i][j]=dp[i-1][j];
}
else{
dp[i][j]=dp[i-1][j-i]+d[i];
}
}
}
}
while(1){
scanf("%d\n",&n);
if(n==0){
break;
}
n=n/100;
printf("%d\n",dp[50][n]);
}
return 0;
}


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

void solve(long long a, long long b, long long x)
{
    /*long long cnt_b = (b / x + (long long)(1.0));
    long long cnt_a = ((a - 1) / x + (long long)(1.0));
    if (cnt_a < 0)
    {
        cnt_a = 0;
    }
    long long ans = cnt_b - cnt_a;
    cout << ans << endl;*/

    if (a > 0)
    {
        cout << b / x - (a - 1) / x << endl;
    }
    else
    {
        cout << b / x + 1 << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long a;
    scanf("%lld", &a);
    long long b;
    scanf("%lld", &b);
    long long x;
    scanf("%lld", &x);
    solve(a, b, x);
    return 0;
}


Measured memory_bytes: 256
S=input()
q=int(input())
s=[]
r=[]
for i in S:
    s.append(i)
t=1
for i in range(q):
    qv=list(input().split())
    if qv[0]=='1':
        t^=1
    else:
        if int(qv[1])^t==0 or int(qv[1])^t==2:
            r.append(qv[2])
        else:
            s.append(qv[2])
            
if t==0:
    ss=s.copy()
    s=[]
    for j in range(len(ss)):
        s.append(ss[-1-j])
    ans=s
    ans.extend(r)
else:
    rr=r.copy()
    r=[]
    for j in range(len(rr)):
        r.append(rr[-1-j])
    ans=r
    ans.extend(s)
answer=''.join(ans)
print(answer)

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

int x1, x2;
int v1, v2;
int t;

int main () {
    while (scanf("%d %d %d %d %d", &x1, &v1, &x2, &v2, &t) == 5) {
        long long l1 = x1 - 1ll * t * v1, r1 = x1 + 1ll * t * v1;
        long long l2 = x2 - 1ll * t * v2, r2 = x2 + 1ll * t * v2;
        if (l1 <= l2 && r1 >= r2) printf("YES\n");
        else printf("NO\n");
    }
}



Measured memory_bytes: 3688
#include <bits/stdc++.h>
#include <boost/format.hpp>

int main(int argc, char *argv[]) {
        int N = 0;
        int M = 0;
        std::cin >> N;
        std::cin >> M;

        std::map<int, std::vector<int>> city_birth_years;

        std::vector<int> prefs;
        std::vector<int> years;

        int p = 0;
        int y = 0;
        for (int i = 0; i < M; i++) {
                std::cin >> p;
                std::cin >> y;
                prefs.push_back(p);
                years.push_back(y);
                if (city_birth_years.find(p) == city_birth_years.end()) {
                        std::vector<int> cities = {y};
                        city_birth_years[p] = cities;
                } else {
                        city_birth_years[p].push_back(y);
                }
        }

        std::set<int> sorted;
        for (int i = 0; i < M; i++) {
                int p = prefs[i];
                int y = years[i];

                if (sorted.find(p) == sorted.end()) {
                        std::sort(city_birth_years[p].begin(), city_birth_years[p].end());
                        sorted.insert(p);
                }

                auto it = std::lower_bound(
                        city_birth_years[p].begin(),
                        city_birth_years[p].end(),
                        y
                );
                int order = (it - city_birth_years[p].begin() + 1);

                std::string id = (boost::format("%06d") % p).str()
                                           + (boost::format("%06d") % (order)).str();
                std::cout << id << std::endl;
        }

        return 0;
}

Measured memory_bytes: 17904
s = gets.chomp.chars
t = gets.chomp.chars
ns = s.count

res = false

res = true if s == t
unless res
  ns.times do |i|
    first = s.delete_at(0)
    s << first
    if s == t
      res = true
      break
    end
  end  
end
puts res ? 'Yes' : 'No'

Measured memory_bytes: 1788
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

template <class T = int>
class CuSum {
private:
	vector<T> cusum;

public:
	CuSum(vector<T> const &vec) : cusum(vec.size() + 1) { for (int i = 0; i < (int)(vec.size()); i++) cusum[i + 1] = cusum[i] + vec[i]; }

	CuSum(int N) : cusum(N + 1) {}
	void add(int i, T x) { cusum[i + 1] += cusum[i] + x; }

	T query(int l, int r) { return cusum[r] - cusum[l]; }  // partial sum of [l, r)
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, Q;
	string S;
	cin >> N >> Q >> S;

	CuSum<int> ACsum(N);
	for (int i = 1; i < N; i++) ACsum.add(i, S[i - 1] == 'A' && S[i] == 'C');

	pair<int, int> range;
	for (int i = 0; i < Q; i++) {
		cin >> range.first >> range.second;
		cout << ACsum.query(range.first, range.second) << "\n";
	}

	return 0;
}

Measured memory_bytes: 1488
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int>d(N);
    
    for(int i = 0; i < N; i++){
        cin >> d[i];
    }
    
    sort(d.begin(), d.end());
    
    
    cout << d[N/2] - d[N/2-1] << endl;
}

Measured memory_bytes: 640
h,n=map(int,input().split())
ls=[list(map(int,input().split())) for i in range(n)]

def dp(h,n,ls):
    table=[[0]*(h+1) for i in range(n)]
    atk,cost=ls[0][0],ls[0][1]
    for x in range(h+1):
        cost_of_this = cost*((x-1)//atk+1) if x!=0 else cost
        table[0][x]=cost_of_this
    for i in range(1,n):
        atk,cost=ls[i][0],ls[i][1]
        for j in range(h+1):
            if atk>=j:
                table[i][j]=min(table[i-1][j], cost)
            else:
                table[i][j]=min(table[i-1][j], table[i][j-atk]+cost)
    return(table[-1][-1])

ans=dp(h,n,ls)
print(ans)


Measured memory_bytes: 118768
#include <stdio.h>
int main(){
  int x, y, z, ans=0;
  scanf("%d %d %d",&x,&y,&z);
  for(int i = x; i <= y; i++){
    if(z % i == 0)ans++;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1852
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 300005;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()

int32_t main()
{ 
  IOS
  
  int a,b;
  cin>>a>>b;
  cout<<a*b<<endl;



  
  

}
 

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

int n,m,par[100010],rnk[100010];
ll size[100010];

int find(int a){
    if(par[a]!=a){
        return par[a]=find(par[a]);
    }
    return a;
}

void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)return;
    if(rnk[a]<rnk[b]){
        par[a]=b;
        size[b]+=size[a];
    }else{
        par[b]=a;
        size[a]+=size[b];
        if(rnk[a]==rnk[b])rnk[a]++;
    }
}

int main(){
    int a[100010],b[100010];
    cin>>n>>m;
    for(int i=0;i<n;i++){
        par[i]=i;
        size[i]=1;
        rnk[i]=1;
    }
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
    }
    ll ans[100010];
    ans[m-1]=(ll)n*(n-1)/2;
    for(int i=m-1;i>=1;i--){
        if(find(a[i])!=find(b[i])){
            ans[i-1]=ans[i]-size[find(a[i])]*size[find(b[i])];
        }else{
            ans[i-1]=ans[i];
        }
        unite(a[i],b[i]);
    }
    for(int i=0;i<m;i++){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 4480