akhauriyash/Code-Regression huggingface dataset:
class UnionFind:
    def __init__(self, size):
        self.rank = [0] * size
        self.par = range(size)
        self.g_num = size

    def find(self, x):
        if x == self.par[x]: return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y: return

        self.g_num -= 1
        if (self.rank[x] > self.rank[y]):
            self.par[y] = x
        else:
            self.par[x] = y
            if (self.rank[x] == self.rank[y]): self.rank[y] += 1

    def group_num(self):
        return self.g_num

n, q = map(int, raw_input().split())
uf = UnionFind(n)
for i in xrange(q):
    c, x, y = map(int, raw_input().split())
    if c == 0:
        uf.unite(x, y)
    else:
        print int(uf.same(x, y))

Measured memory_bytes: 4500
N,Q=(int(i) for i in input().split())
x=input()
a=[]

j=0
s=[0]
t=0
while (j<N-1):
  if (x[j]=="A") and (x[j+1]=="C"):
    t+=1
    s.append(t)
  else:s.append(t)
  j+=1
for i in range(0,Q):
  a.append([int(j) for j in input().split()])
  p=s[a[i][1]-1]-s[a[i][0]-1]
  print(p)





Measured memory_bytes: 24136
def solve(n, m, k, a, b, c, d):
    V = range(1,n+1)
    parents = {x:x for x in V}
    def root(x):
        return x if x == parents[x] else root(parents[x])
    friends = {x:0 for x in V}
    for i in range(m):
        x, y = a[i], b[i]
        friends[x] += 1
        friends[y] += 1
        x = root(x)
        y = root(y)
        if x > y:
            x, y = y, x
        parents[y] = x
    group = {x:0 for x in V}
    for x in V:
        group[root(x)] += 1
    blocks = {x:0 for x in V}
    for i in range(k):
        x = root(c[i])
        y = root(d[i])
        if x == y:
            blocks[c[i]] += 1
            blocks[d[i]] += 1
    res = [group[root(x)] - friends[x] - blocks[x] - 1 for x in V]
    return " ".join(map(str, res))

n, m, k = map(int, input().split())
a = [0] * m
b = [0] * m
for i in range(m):
    a[i], b[i] = map(int, input().split())
c = [0] * k
d = [0] * k
for i in range(k):
    c[i], d[i] = map(int, input().split())
print(solve(n, m, k, a, b, c, d))

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

using namespace std;

typedef long long int ll;

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

typedef pair<int,int> pair;

int main(){
    string s;
    int ans=0;
    cin >> s;

    if(s[0]==s[1] && s[1]==s[2]){
        puts("No");
        return 0;
    }
    puts("Yes");
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <map>
#include <deque>
#include <iostream>
#include <queue>
#include <math.h>
#include <algorithm>
#include <fstream>

using namespace std;
typedef long long ll;


int main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> tmp(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	tmp = a;
	sort(a.begin(), a.end());
	int max = a[n-1];
	for (int i = 0; i < n; i++) {
		if (tmp[i] == max) {
			cout << a[n - 2]<<endl;
		}
		else {
			cout << max << endl;
		}
	}

	
	return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
//=======================
const int MOD = 1000000007;
const int N = 2e6+13, M = N;
//=======================
vi g[N];
int a[N];
int n, m, k,cnt=0;
//=======================

void solve() {
  cin >> n;
     fo(i, n)
     {
         cin >> m >> k;
         if(m == k)
            cnt++;
            
        else
        {
            cnt = 0;
        }
        if(cnt == 3)
        {
            cout << "Yes\n";
            return;
        }
        
     }
     cout << "No\n";
     return;
}

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

    int t = 1;
    while(t--) {
      solve();
    }

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int m[10][10] = {};
  for (int i = 1; i <= N; i++) {
    int n = i;
    while (n >= 10) n /= 10;
    m[i % 10][n]++;
  }
  ll ret = 0;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      ret += m[i][j] * m[j][i];
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <vector>
#include <fstream>
using namespace std;
const int nmax=100005;
deque<int> dq;
vector<int> v[nmax];
int in[nmax];
int n,i,a,b,m;
int bag_a,bag_b,oka,okb,st,dr;
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dq.push_back(1);in[1]=1;
    while((!oka)||(!okb))
    {
        st=dq.front();dr=dq.back();
        bag_a=bag_b=0;
        if(!oka)
        for(int i=0;i<v[st].size();i++)
            if(!in[v[st][i]])
        {
            bag_a=v[st][i];
        }
        if(!okb)
        for(int i=0;i<v[dr].size();i++)
            if(!in[v[dr][i]])
        {
            bag_b=v[dr][i];
        }
        if(!bag_a) oka=1;
        else dq.push_front(bag_a);
        if(!bag_b) okb=1;
        else if(bag_a!=bag_b)dq.push_back(bag_b);
        in[bag_a]=in[bag_b]=1;
    }
    cout<<dq.size()<<'\n';
    for(i=0;i<dq.size();i++)
        cout<<dq[i]<<' ';
    return 0;
}


Measured memory_bytes: 7040
def main():
    import sys

    readline = sys.stdin.readline

    while True:
        N = int(readline().rstrip())
        if N == 0:
            break

        dp = [0] * (N + 1)
        dp[0] = 1
        
        for i in range(1, N + 1):
            if i == 1:
                dp[i] += dp[i - 1]
            elif i == 2:
                dp[i] += dp[i - 1] + dp[i - 2]
            else:
                dp[i] += dp[i - 1] + dp[i - 2] + dp[i - 3]
        print(-(-dp[-1] // 3650))


main()



Measured memory_bytes: 5604
#include <stdio.h>

int main(void) {
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else {
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 1716
//B
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,ans;
    cin >> A >> B;
    if(A >= 13) ans = B;
    if(6 <= A && A<= 12) ans = B/2;
    if(A <6) ans = 0;

    cout << ans << endl;
}

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

int main() {
    string A,B;
    cin>>A>>B;
    if(A.size()>B.size()){
        cout<<"GREATER"<<endl;
        return 0;
    }else if(A.size()<B.size()){
        cout<<"LESS"<<endl;
        return 0;
    }else{
        for(int i=0;i<A.size();i++){
            if(A.at(i)>B.at(i)){
                cout<<"GREATER"<<endl;
                return 0;
            }else if(A.at(i)<B.at(i)){
                cout<<"LESS"<<endl;
                return 0;
            }else{}
        }
    }
    cout<<"EQUAL"<<endl;
return 0;}
/*
g++ code.cpp
./a.out
*/

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

using namespace std;
using ll = long long;

struct node {
    ll val;
    node *next;
    node *prev;

    node(ll x) {
        val = x;
    }
} *root;

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

    sort(a.begin(), a.end(), greater <ll>());

    if (n == 2) {
        cout << a[0] << endl;
        return 0;
    }

    if (n == 3) {
        cout << a[0] + a[1] << endl;
        return 0;
    }

    root = new node(a[0]);
    node *n1 = new node(a[1]);
    node *n2 = new node(a[2]);

    root->next = n1;
    root->prev = n2;

    n1->next = n2;
    n1->prev = root;

    n2->next = root;
    n2->prev = n1;

    node *curr = root;

    ll ans = a[0] + a[1];

    for (int i = 3; i < n; i++) {
        node *temp = new node(a[i]);
        ans += min(curr->val, curr->next->val);
        temp->prev = curr;
        temp->next = curr->next;

        curr->next = temp;
        temp->next->prev = temp;
        curr = temp->next;
    }

    cout << ans << endl;
}


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
#define debug(x) cout << #x << " = " << x << endl;
// template starts
typedef long long int ll;

// template ends here
int h, w,K;
vector<string> grid;
	
int tot = 0;

bool check(vector<bool> &x, vector<bool> &y){
	
	//print(x,0,h-1);
	//print(y,0,w-1);
	
	
	//cout << endl;
	set<pair<int,int>> s;
	
	for(int i = 0; i < (int)x.size(); i++){
		if(!x[i]) continue;
		
		for(int j = 0; j < w; j++){
			if(grid[i][j] == '.') continue;
			
			s.insert(mp(i,j));
		}
	}
	for(int i = 0; i < (int)y.size(); i++){
		if(!y[i]) continue;
		
		for(int j = 0; j < h; j++){
			if(grid[j][i] == '.') continue;
			s.insert(mp(j,i));
		}
	}
	//debug(s.size());
	return tot-(int)s.size() == K;
}

void solve(){
	// code starts from here
	cin >> h >> w >> K;
	
	grid.resize(h);
	
	for(int i = 0; i < h; i++) cin >> grid[i];
	int ans = 0;
	
	for(int i = 0; i < h; i++){
		for(char ch: grid[i]) if(ch == '#')tot++;
	}

	for(int k = 0; k < (1<<h); k++){
		vector<bool> x(h,false);
		int index = 0;
		
		int t = k;
		while(t != 0){
			x[index] = t%2;
			index++;
			t /= 2;
		}
					
		for(int l = 0; l < (1<<w); l++){
			vector<bool> y(w,false);
			int index2 = 0;
		
			t = l;
			while(t != 0){
				y[index2] = t%2;
				index2++;
				t /= 2;
			}
			
			
			if(check(x,y)) ans++;
		}
	}
		
	cout << ans << endl;
}

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

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 3644
import sys
sys.setrecursionlimit(200000)

N = int(input())
A = list(map(int,input().split()))
dp = [-1]*(N+100010)
dp[0] = 0
dp[1] = abs(A[1] - A[0])


def rec(i):
  if dp[i] != -1:
    return dp[i]
  dp[i] = min(rec(i-1) + abs(A[i-1] - A[i]), rec(i-2) + abs(A[i-2] - A[i]))
  return dp[i]

print(rec(N-1))


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    int N; cin >> N;
    int d[100005];
    for (int i = 0;i < N;i++){
        cin >> d[i];
    }
    sort(d,d+N);

    cout << d[N/2]-d[N/2-1] << endl;

    return 0;

}

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

int main() {
	int n;
	int d[110][2] = {};
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i][0] >> d[i][1];
	}
	int count = 0;
	for (int j = 0; j < n; j++) {
		if (count == 3) break;

		if (d[j][0] == d[j][1]) ++count; 
		else if (d[j][0] != d[j][1]) count = 0;
	}
	cout << (count == 3 ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 3056
fun main(args: Array<String>) {
    val n = readInt()
    val x = readIntList()

    val s = x.sorted()
    val l = s[n / 2 - 1]
    val r = s[n / 2]
    val th = (l + r) / 2.0

    x.forEach {
        if (it <= th) {
            println(r)
        } else {
            println(l)
        }
    }
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)

Measured memory_bytes: 76432
import java.util.Scanner;

public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextInt();
        int ans=0;
        for (long i=N;i>0 ;i--){
            int a = (int)Math.sqrt(i);
            if(a*a == i){
                ans =(int)i;
                break;
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
	int n, arr[200005];
	map<int, int> mps;
	scanf("%d", &n);
	for(int i = 0;i < n;i++){
		scanf("%d", &arr[i]);
		mps[arr[i]]++;
	}int ans = 0;
	for(int i = 0;i < n;i++){
		if(mps[arr[i]] > 1) continue;
		if(arr[i] == 1){
			if(mps[1] == 1) ans++;
			continue;
		}
		int f = 1;
		bool ada = false;
		while(f * f <= arr[i]){
			if(arr[i] % f == 0){
				if(mps[f]) ada = true;
				if(mps[arr[i]/f]){
					if(arr[i] / f != arr[i]) ada = true;
					else{
						if(mps[arr[i]] > 1) ada = true;
					}
				}
			}
			if(ada) break;
			f++;
		}
		if(ada) continue;
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 33476
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include <iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X=X;}
#define TF(f) {f=f;}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 1000000;
#define NMAX 50
#define MAX 10

    int N,M,A[100010],B;
    string S;
    ll X,ans=0;


    bool f[100010];


int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N)cin>>A[i];
    REP(i,N){
      if(!(f[A[i]])){f[A[i]]=true;ans++;}
      else {B++;}
    }
    cout<<ans-(B%2)<<endl;


}
//ABC057 Maximum Average Sets


Measured memory_bytes: 768
#include <stdio.h>

int main(){
  
  int a,b;
  scanf("%d %d",&a,&b);
  if(a>b){
    printf("%d",2*a-1);
  } else if(a==b){
    printf("%d",2*a);
  } else {
    printf("%d",2*b-1);
  }
  
  return 0;
    
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String O = sc.next();
		String E = sc.next();
		int o = O.length();
		int e = E.length();
		for(int i = 0 ; i < o ; i++) {
			System.out.print(String.valueOf(O.charAt(i)));
			if(e > i) {
				System.out.print(String.valueOf(E.charAt(i)));
			}
		}
	}
}


Measured memory_bytes: 21972
R, G, B, N = map(int, input().split())

Max = max(R, G, B)
Min = min(R, G, B)
Mid = R+G+B - Max - Min
ans = 0

for i in range((N // Max) +1):
    rem1 = N - (i*Max)
    for j in range((rem1 // Mid) +1):
        rem2 = rem1 - (j*Mid)
        if rem2 % Min == 0:
            ans += 1

print(ans)


Measured memory_bytes: 3064
// 1_6_D
#include<stdio.h>

int main(void)
{
	int n, m, i, j;
	int matrix[100][100];
	int vector[100];
	int ans = 0;

	scanf("%d %d", &n, &m);

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

	for(j = 0; j < m; j++){
		scanf("%d", &vector[j]);
	}

	for(i = 0; i < n; i++){
		for(j = ans = 0; j < m; j++){
			ans += matrix[i][j] * vector[j];
		}
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 636
package main
import (
	"fmt"
	"os"
	"bufio"
	"strconv"
)

var stdin = bufio.NewScanner(os.Stdin)

func Input_int() int {
	stdin.Scan()
	out,err := strconv.Atoi(stdin.Text())
	if err != nil{
		panic(err)
	}
	return out
}

func main(){
	stdin.Split(bufio.ScanWords)
	N := Input_int()
	var H []int
	for i:=0;i<N;i++{
		H = append(H,Input_int())
	}
	count := 1
	for i:=1;i<N;i++{
		flag := true
		for j:=0;j<i;j++{
			if(H[i] < H[j]){
				flag = false
				break;
			}
		}
		if flag{
			count++
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 640
import java.util.Scanner;

class Tower{
  int hight;
  boolean good = true;
}

public class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    
    int N = scan.nextInt();
    int M = scan.nextInt();
    
    Tower[] tower = new Tower[N];
    
	for(int n = 0; n < N; n++){
      tower[n] = new Tower();
      tower[n].hight = scan.nextInt();
    }
    
    int el;
    int pt;
    for(int m = 0; m < M; m++){
      el = scan.nextInt()-1;
      pt = scan.nextInt()-1;
      if(tower[el].hight > tower[pt].hight){
        if(tower[pt].good){
          N--;
          tower[pt].good = false;
        }
      }else if(tower[el].hight < tower[pt].hight){
        if(tower[el].good){
          N--;
          tower[el].good = false;
        }
      }else{
         if(tower[pt].good){
          N--;
          tower[pt].good = false;
        }
        if(tower[el].good){
          N--;
          tower[el].good = false;
        }
      }
    }
    
    System.out.println(N);
  }
}

Measured memory_bytes: 62416
count1 = 0
count2 = 0
num = input()
le = len(num)

for n in range(le):
    if n%2 == 0:
        if num[n] == "0":
            count1 += 1
    else:
        if num[n] == "1":
            count1 += 1
for n in range(le):
    if n%2 == 0:
        if num[n] == "1":
            count2 += 1
    else:
        if num[n] == "0":
            count2 += 1
print(min(count1,count2))

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] b = new int[n - 1];
    int ans = 0;

    for (int i = 0; i < (n - 1); i++) {
      b[i] = sc.nextInt();
    }

    for (int i = 0; i < (n - 2); i++) {
      ans += Math.min(b[i], b[i + 1]);
    }

    ans += b[0];
    ans += b[n - 2];

    System.out.println(ans);

  }
}

Measured memory_bytes: 35984
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Set<Integer> num = new HashSet<>();
        for (int i = 0; i<N; i++) {
            int di = sc.nextInt();
            num.add(di);
        }
        System.out.println(num.size());
    }
}

Measured memory_bytes: 23124
import java.util.Scanner;
public class Main {
	public static void main(String []args) {
		Scanner sc=new Scanner(System.in);
		double r=sc.nextDouble();
		System.out.println(String.format("%.6f", r*r*Math.PI)+" "+String.format("%.6f", 2*Math.PI*r));
	}
}



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

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    if(a >= b && b >= c) cout << abs(a - b) + abs(b - c) << endl;
    else if(a >= c && c >= b) cout << abs(a - c) + abs(c - b) << endl;
    else if(b >= c && c >= a) cout << abs(b - c) + abs(c - a) << endl;
    else if(b >= a && a >= c) cout << abs(b - a) + abs(a - c) << endl;
    else if(c >= b && b >= a) cout << abs(c - b) + abs(b - a) << endl;
    else cout << abs(c - a) + abs(a - b) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
range = xrange
input = raw_input

m,k = [int(x) for x in input().split()]

if (m==1 and k==1) or k>=2**m:
    print -1
    sys.exit()

if k==0:
    A = list(range(2**m))
    print ' '.join(str(a) for a in (A + A[::-1]))
    sys.exit()

A = [i for i in range(2**m) if i != k]

A = A + [k] + A[::-1] + [k]

if len(A)!=2**(m+1):
    print -1
    sys.exit()

xorsum = [0]
for a in A:
    xorsum.append(xorsum[-1]^a)

index = [-1]*(2**m)
for i in range(len(A)):
    if index[A[i]] == -1:
        index[A[i]] = i
    else:
        j = index[A[i]]
        if (xorsum[i+1]^xorsum[j])!=k:
            print -1
            sys.exit()

print ' '.join(str(a) for a in A)

Measured memory_bytes: 71020
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();   //奇数
        int[] dam = new int[N];
        int[] ans = new int[N];
        
        int sumRain = 0;
        for(int i = 0; i < N; i++){
            dam[i] = sc.nextInt();
            ans[i] = 0;
            sumRain += dam[i];
        }

        int sum = 0; 
        for(int i = 1; i < N; i += 2){
            sum += dam[i] * 2;
        }

        ans[0] = sumRain - sum;
        for(int i = 0; i < N-1; i++){
            ans[i+1] = dam[i]*2 - ans[i];
        }

        for(int i = 0; i < N; i++){
            System.out.print(ans[i] + " ");
        }
    }
}


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

int main()
{
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	
	sort(a,a+n);
	long long com=0LL;
	int k=n-1;
	for(int i=n-1;k>0; )
	{
		com+=(long long)a[i];
		k--;
		if(i!=n-1 && k)
		{
			com+=(long long)a[i];
			k--;
		}
		i--;
		//cout << k << endl;
	}
	
	cout << com ;
}

Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    int n, r;
    cin >> n >> r;
    while(!(n==0 && r==0)){
        vector<int> a(n);
        REP(i, n) a[i] = n-i;
        REP(i, r){
            int p, c;
            cin >> p >> c;
            p--;
            vector<int> a_cp(a);
            REP(i, n){
                if(i < c) a_cp[i] = a[p+i];
                else if(i < c+p) a_cp[i] = a[i-c];
                else a_cp[i] = a[i];
            }
            copy(All(a_cp), a.begin());
        }
        cout << a[0] << "\n";
        cin >> n >> r;
    }
    return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define  st first
#define  nd second
#define int long long 


template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef cc_hash_table<int, int, hash<int > > ht;

const int  M    = 1000000007;
const int  maxn =  100005 ;
const long long   inf  =  LONG_LONG_MAX    ;
const long double eps = 1.084202e-19;



int32_t main(){
     ios_base::sync_with_stdio(false);
     cin.tie(NULL); 
     string s , t;
     cin  >> s >> t ; 
     int n = s.size() ; 
     int m = t.size();
     int ma = inf;
     for(int i = 0 ; i<=n-m;i++){
           int ans = 0 ;
           for(int j = 0 ; j<m ; j++){
                 if(s[i+j]!=t[j]){
                       ans++;
                 }
           }
           ma = min(ma,ans);
     }
     cout << ma ;

}
/*

*/

Measured memory_bytes: 3656
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

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


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n=nxt();
    ll prod=n*360;
    prod/=__gcd(n,360*1LL);
    cout<<prod/n<<endl;
	printclock;
	return 0;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;
			
void solve() {
	int n; 
	cin >> n;
	int arr[n];
	ll cnt = 0;
	for(int i = 0; i < n; ++i) cin >> arr[i];	
	sort(arr, arr + n);
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			for(int k = j + 1; k < n; ++k) {
				if(arr[i] == arr[j]) continue;
				else if(arr[i] == arr[k]) continue;
				else if(arr[k] == arr[j]) continue;	
				if(arr[i] + arr[j] > arr[k]) cnt++;
				}
			}
		}
		cout << cnt << endl;
}


	

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
}






Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    if (k == 0) {
        cout << (ll)n*n << endl; 
        return 0;
    }
    for (int b = 1; b <= n; ++b) {
        if (b <= k) continue;
        ans += (b-k) * ((n+1)/b);
        if ((n+1)%b > k) ans += (n+1)%b-k;
    }

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

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

#define i64 long long int

i64 A, B;
double b;

int main() {
	scanf("%lld%lf", &A, &b);
	B = int((b+1e-9)*100);
	printf("%lld\n", A*B/100);
	
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll a,b,c,d;cin >>a>>b>>c>>d;
    bool flg=false;
    if(abs(a-c)<=d)flg=true;
    if(abs(b-a)<=d&&abs(c-b)<=d)flg=true;
    if(flg)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//オブジェクト生成
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		ArrayList<Integer> minNumList = new ArrayList<Integer>();

		//代入作業
		int num1 = scan.nextInt();
		int buyCnt = scan.nextInt();
		for (int i = 0; i < num1; i++) {
			list.add(scan.nextInt());
		}

		int minNum = 0;
		int[] minNumArray = new int[buyCnt];
		for (int j = 0; j < buyCnt; j++) {
			minNum = list.get(0);
			for (int i = 1; i < num1 - j; i++) {
				if (minNum < list.get(i)) {
					//何もしない
				} else {
					minNum = list.get(i);
				}
			}
			minNumArray[j] = minNum;
			list.remove(list.indexOf(minNum));
		}

		int ans = 0;
		for (int i = 0; i < minNumArray.length; i++) {
			ans += minNumArray[i];
		}

		System.out.println(ans);

	}

}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll N; cin >> N;

    ll sum = 0;
    sum = N * (N-1) / 2;

    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
int digit(int x){
    int cnt = 0 ;
    while(x != 0){
        x /= 10 ;
        cnt++ ;
    }
    return cnt ;
}
int POW(int x, int y){
    int ans = 1;
    for(int i = 0; i < y; i++){
        ans *= x ;
    }
    return ans ;
}
signed main(){
    fastio
    int n ; 
    cin >> n ;
    map<pair<int,int>, int > mp ;
    for(int i = 1; i < n + 1; i++){
        pair<int,int> p = make_pair(i / POW(10, digit(i) - 1), i % 10);
        mp[p]++;
    }
    int ans = 0 ;
    for(int i = 1; i < n + 1; i++){
        int first = i / POW(10, digit(i) - 1) ;
        int last = i % 10 ;
        if ( mp.count(make_pair(last, first)) ){
            ans += mp[make_pair(last, first)];
        }
    }
    cout << ans << endl;
    return 0; 
}

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

using namespace std;

int main(){
    int n,m,r;
    cin>>n>>m>>r;
    vector<int>t(r);
    for(int i=0;i<r;++i){
        cin>>t[i];
    }
    vector<vector<long long>>dist(n+1,vector<long long>(n+1,1e9));
    for(int i=0;i<m;++i){
        int a,b,c;
        cin>>a>>b>>c;
        dist[a][b]=c;
        dist[b][a]=c;
    }
    for(int k=1;k<n+1;++k){
        for(int i=1;i<n+1;++i){
            for(int j=1;j<n+1;++j){
                if(dist[i][j]>dist[i][k]+dist[k][j]){
                    dist[i][j]=dist[i][k]+dist[k][j];
                }
            }
        }
    }
    long long ans=1e18;
    sort(t.begin(),t.end());
    do{
        long long d=0;
        for(int i=0;i<r-1;++i){
            d+=dist[t[i]][t[i+1]];
        }
        if(ans>d)ans=d;
    }while(next_permutation(t.begin(),t.end()));
    cout<<ans<<endl;
}


Measured memory_bytes: 512
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,v=LI()
  b,w=LI()
  t=I()

  sa=abs(a-b)

  if sa-(v*t-w*t)<=0:
    return 'YES'

  return 'NO'

# main()
print(main())


Measured memory_bytes: 10752
///============================================================================
/// Name        : Faisal.cpp
/// Author      : Faisal Ahmed
/// Version     :
/// Copyright   : Your copyright notice
/// Description : C++, Ansi-style
///============================================================================

#include <bits/stdc++.h>

using namespace std;

#define M 1000000007

typedef long long int ll;
typedef long double ld;

ll a[100010], b[100010];

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

	ll n;
	ll ans = 1;

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

	for(int i = 1; i <= n; i++){
        int d = abs((n - i) - (i - 1));
  //      cout << "d = " << d << endl;
        b[d]++;
	}

	for(int i = 0; i < n; i++){
	 //   cout << "b = " << b[i] << " " << a[i] << endl;
        if(b[i] >= a[i] && a[i] > 0){
       //     cout << "a = " << a[i] << " " << i << endl;
            ans = (((ll)ans % (ll)M) * ((ll)a[i] % (ll)M)) % M;
        }
        else if(a[i] > b[i]){
            ans = 0;
        }
    //    cout << "ans = " << ans << endl;
	}

	cout << ans % M << endl;

	return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


ull p[1001];
const ull prime=1000000007;

// 文字列のrolling hashをコンストラクタに渡された素数と
// 渡された文字列により計算し、getRollingHashでそれを戻す
class RollingHash{
private:
    ull ary[1001];
    int N;// 文字列長
public:
  RollingHash(const string &str){
    N=str.size();
    // prime**iを計算
    // ハッシュ値を計算
    ary[0]=0;
    for(int i=1;i<=N;i++)
        ary[i]=ary[i-1]*prime+str[i-1];;
  }
    RollingHash(){}
  // 先頭をx,終端をyで指定し、その範囲のハッシュ値を取り出す
  ull getHash(const int x,const int y)const{
    return ary[y+1]-ary[x]*p[y-x+1];
  }
  // 自身の[x1,y1]の範囲でのハッシュ値と
  // rの[x2,y2]の範囲のでのハッシュ値が一致するか調べる
  bool isMatch(const int x1,const int y1,const int x2,const int y2,const RollingHash &r)const{
    return this->getHash(x1,y1)==r.getHash(x2,y2);
  }
};


int N;
string field[301];
RollingHash* rhs[301];
RollingHash chs[301];

int main(){


    fastStream();
    cin >> N;
    for(int i = 0; i < N; i++)
        cin >> field[i];

    p[0]=1;
    for(int i=1;i<N+5;i++)
        p[i]=p[i-1]*prime;


    int ans = 0;
    for(int i = 0; i < N; i++)
        rhs[i] = new RollingHash(field[i]);

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

        for(int j = 0; j < N; j++){
            string s;
            for(int k = 0; k < N; k++)
                s += field[(k + A) % N][j];
            chs[j] = RollingHash(s);
        }
        
        {
            bool ok = true;
            for(int k = 0; k < N; k++){
                if(rhs[k]->getHash(0, N-1) != chs[k].getHash(0, N-1)){
                    ok = false;
                }
            }
            ans += ok;
        }

        for(int B = 1; B < N; B++){
            bool ok = true;
            int idx = (N-B);
            for(int i = 0; i < N; i++){
                if(!(rhs[i]->getHash(0, N-1-B) == chs[idx].getHash(B, N-1)
                     && rhs[i]->getHash(N-B, N-1) == chs[idx].getHash(0, B-1))){
                    ok = false;
                    break;                    
                }
                idx++;
                if(idx >= N)idx -= N;
            }
            ans += ok;
        }

        RollingHash *h = rhs[0];
        for(int i = 0; i < N-1; i++){
            rhs[i] = rhs[i+1];
        }
        rhs[N-1] = h;

    }
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 4608
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
vector<vector<ll> > memo(51,vector<ll>(51,-INF));
ll pascal(ll n, ll k){
    if(memo[n][k]!=-INF) return memo[n][k];
    if(n<k) return memo[n][k]=0;
    if(n<0 || k<0) return memo[n][k]=0;
    if(k==0) return memo[n][k]=1;
    return memo[n][k]=pascal(n-1,k)+pascal(n-1,k-1);
}

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll A,B,X; cin>>A>>B>>X;
    if(A==0) cout<<(B/X)+1<<endl;
    else cout<<(B/X)-((A-1)/X)<<endl;
}



Measured memory_bytes: 3596
import java.util.Scanner;

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

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println(N * A < B ? N * A : B);
	}
}

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

int main()
{
    string S; cin >> S;
    int N = S.size();
    string tmp = S.substr(0, 1);
    int ans = 1;
    for(int i = 1; i < N; i++){
      if(S.substr(i, 1) != tmp){
        tmp = S.substr(i, 1);
        ans++;
      }else{
        if(i != N - 1){
          tmp = S.substr(i, 2);
          ans++;
          i++;
        }else{
          break;
        }
      }
    }

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


Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    int ans = 0;
    //vector<vector<int>> SW;

    int SW[10][10];
    int KN[10];

    for ( int i = 0; i < M; ++i ) {
        int kn;
        cin >> kn;
        KN[i] = kn;
        for ( int j = 0; j < kn; ++j ) {
            cin >> SW[i][j];
        }
    }

    int P[10];

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

    for ( int bit = 0; bit < (1 << N); ++bit ) {
        int flag = 0;
        for ( int i = 0; i < M; ++i ) {
            int count = 0;
            for ( int j = 0; j < KN[i]; ++j ) {
                if ( bit & (1 << (SW[i][j]-1)) ) ++count;
            }
            if ( count % 2 != P[i] ) flag = 1;
        }
        if ( !flag ) ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int x, a, b;
/*==================================================*/
/*function*/

/*==================================================*/

int main() {

    cin>>x>>a>>b;

    if(abs(x-a) < abs(x-b)){
        cout<<"A"<<endl;
    }else{
        cout<<"B"<<endl;
    }


    return 0;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<int,int> p;

int n;
ll t[200];

ll gcd(ll a, ll b){
  if(a%b!=0)return gcd(b,a%b);
  else return b;
}
ll lcm(ll a, ll b){
  ll hoge = b/gcd(a,b);
  return a*hoge;
}

int main(){
  cin >> n;
  cin >> t[0];
  ll x = t[0];
  rep(i,1,n){
    cin >> t[i];
    x = lcm(t[i], x);
  }
  cout << x << endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.nextLine());
        int b = Integer.parseInt(sc.nextLine());
        int c = Integer.parseInt(sc.nextLine());
        int d = Integer.parseInt(sc.nextLine());
        int e = Integer.parseInt(sc.nextLine());
        int k = Integer.parseInt(sc.nextLine());
        
        int a1 = (int)Math.abs(a-b);
        int a2 = (int)Math.abs(a-c);
        int a3 = (int)Math.abs(a-d);
        int a4 = (int)Math.abs(a-e);
        
        int b1 = (int)Math.abs(b-c);
        int b2 = (int)Math.abs(b-d);
        int b3 = (int)Math.abs(b-e);
        
        int c1 = (int)Math.abs(c-d);
        int c2 = (int)Math.abs(c-e);
        
        int d1 = (int)Math.abs(d-e);
        
        if (a1 <= k &&
            a2 <= k &&
            a3 <= k &&
            a4 <= k &&
            b1 <= k &&
            b2 <= k &&
            b3 <= k &&
            c1 <= k &&
            c2 <= k &&
            d1 <= k ) {
                System.out.println("Yay!");
            } else {
                System.out.println(":(");
            }
    }
}


Measured memory_bytes: 22612
#include<bits/stdc++.h> /*
*/
#include<algorithm>
#define ll long long
#define eps 1e-10
#define endl "\n"
using namespace std;

int main()
{
    //ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int sl=s.length();
    int tl=t.length();
    int maxi=INT_MAX;
    int ct=0;
    for(int i=0;i<=sl-tl;i++)
    {
        ct=0;
        int k=0;
        for(int j=0;j<tl;j++)
        {
            if(s[i+k]!=t[j])
            {
                ct++;
            }
            k++;
        }
        maxi=min(ct,maxi);
    }
    cout<<maxi<<endl;

    return 0;
}



Measured memory_bytes: 3656