akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll inf=1e18;
ll p=1e9+7;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll i,j,t,w,h,a,x,y,r,k,d,s;
	cin>>s>>w;
	if(w>=s)
	cout<<"unsafe";
	else
	cout<<"safe";
	
	
	
	return 0;
	
	
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <cmath>
typedef long long LL;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(){
  LL N;
  cin >> N;
  vector<LL> H(N);  
  
  rep(i,N){
    cin >> H[i];
  }
  
  bool noflag=false;
  for(int i=N-1;i>0;i--){
    LL comp = H[i]-H[i-1];
    
    if(comp==-1){
    	H[i-1]--;
    }else if (comp <= -2){
      cout<<"No";
      return 0;
    }
  }
  
  cout << "Yes";
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  vector<int> Q(N);
  for(int i = 0;i < N;i++){
    cin >> P[i];
  }
  for(int i = 0;i < N;i++){
    cin >> Q[i];
  }
  vector<int> a(N);
  for(int i = 0;i < N;i++){
    a[i] = i+1;
  }
  map<vector<int>,int> m;
  do{
    m[a] = m.size();
  }while(next_permutation(a.begin(),a.end()));
  cout << abs(m[P]-m[Q]) << endl;
}

Measured memory_bytes: 5248
#include<iostream>
#include<algorithm>

using namespace std;

int v, n, dis[15][15];
int dp[(1 << 15)][15];
const int INF = 100000000;

int main() {
	cin >> v >> n;
	for (int i = 0; i < v; i++)for (int j = 0; j < v; j++)dis[i][j] = INF;
	for (int i = 0; i < (1 << v); i++)for (int j = 0; j < v; j++)dp[i][j] = INF;
	for (int i = 0; i < n; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		dis[a][b] = c;
	}
	dp[0][0] = 0;
	for (int i = 0; i < (1 << v) - 1; i++) {
		for (int j = 0; j < v; j++) {
			if (i && !(i & (1 << j)))continue;
			for (int k = 0; k < v; k++) {
				if (j == k)continue;
				if (!(i & (1 << k))) {
					dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k], dp[i][j] + dis[j][k]);
				}
			}
		}
	}
	if (dp[(1 << v) - 1][0] == INF)cout << -1 << endl;
	else cout << dp[(1 << v) - 1][0] << endl;
	return 0;
}

Measured memory_bytes: 4964
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        if(a<b){
        System.out.println("a < b");
        }else if (b<a){
        System.out.println("a > b");
        }else if(a==b){
        System.out.println("a == b");
        }
        
    }
}    
          

Measured memory_bytes: 26032
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;

/*
struct Edge{
    int u,v,weight;
    bool operator<(Edge const& other) {
        return weight<other.weight;
    }
};

vector<int> parent,rank;

void make_set(int v) {
    parent[v]=v;
    rank[v]=0;
}

int find_set(int v) {
    if(v==parent[v])
        return v;
    return parent[v]=find_set(parent[v]);
}

void union_sets(int a,int b) {
    a=find_set(a);
    b=find_set(b);
    if(a!=b){
        if(rank[a]<rank[b])
            swap(a,b);
        parent[b]=a;
        if(rank[a]==rank[b])
            rank[a]++;
    }
}*/
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}
/*
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2; p*p<=n; p++)
        if (prime[p] == true)
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
char s[25][25];
int h,w;
int dx[4]={-1,+1,0,0};
int dy[4]={0,0,-1,+1};

int bfs(int k,int l){
	int vst[h+2][w+2],cst[h+2][w+2];
	rep(i,0,h+2)rep(j,0,w+2){
		vst[i][j]=0;
		cst[i][j]=0;
	}
	queue <pii> q;
	q.push(mkp(k,l));
	cst[k][l]=0;
	vst[k][l]=1;
	int mx=0;
	while(!q.empty()){
		int x=q.front().fi;
		int y=q.front().se;
		q.pop();
		rep(i,0,4){
			int m=x+dx[i];
			int n=y+dy[i];
			if(m<1||n<1||m>h||n>w||s[m][n]=='#')continue;
			else if(vst[m][n]==0){
				vst[m][n]=1;
				cst[m][n]=1+cst[x][y];
				q.push(mkp(m,n));
				mx=max(mx,cst[m][n]);
			}
		}
	}	
	return mx;
}

int solve(){
    cin>>h>>w;
    int maxi=0;
	rep(i,1,h+1)rep(j,1,w+1)cin>>s[i][j];
	rep(i,1,h+1){
		rep(j,1,w+1){
			if(s[i][j]=='.'){
				maxi=max(maxi,bfs(i,j));
			}
		}
	}
	cout<<maxi<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 256
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))


from collections import defaultdict, deque, Counter
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
from heapq import *
import sys

# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 1000000007

from fractions import *


def inverse(f):
    # return Fraction(f.denominator,f.numerator)
    return 1 / f


def combmod(n, k, mod=MOD):
    ret = 1
    for i in range(n - k + 1, n + 1):
        ret *= i
        ret %= mod

    for i in range(1, k + 1):
        ret *= pow(i, mod - 2, mod)
        ret %= mod

    return ret

MOD = 10 ** 9 + 7

def yaku(n):
    res = []
    for i in range(2, int(math.sqrt(n)) + 2):
        tmp = 0
        while(True):
            if n % i == 0:
                tmp += 1
                n //= i
            else:
                break
        if tmp != 0:
            res.append((tmp, i))
    if n != 1:
        res.append((1, n))
    return res

def solve():
    n = getN()
    lis = []
    for i in range(n):
        lis.append(getN())

    lis.sort()
    prev = 0
    res = []
    for idx, num in enumerate(lis):
        if (num - prev) % 2 == 1:
            res.append(idx + 1)
        prev = num
    ans = 0
    for re in res:
        ans = ans ^ re

    if ans != 0:
        print("first")
    else:
        print("second")
    # print(res)
    return
def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    solve()

Measured memory_bytes: 76628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll r = 0, g = 0, b = 0;
    rep(i, 0, n) {
        if (s[i] == 'R') r++;
        if (s[i] == 'G') g++;
        if (s[i] == 'B') b++;
    }
    ll ans = r * g * b;
    rep(i, 0, n - 2) {
        rep(j, i + 1, n - 1) {
            int d = j - i;
            int k = j + d;
            if (k >= n) continue;
            if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define N 6010
using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int n,k,tmp,F[N],a[N];
inline bool check(int x)
{
	if(a[x]>=k) return 1;
	memset(F,0,sizeof F); F[0]=1;
	for(int i=1;i<=n;i++) if(i!=x)
		for(int j=k;j>=a[i];j--)
			F[j]|=F[j-a[i]];
	for(int i=k-a[x];i<k;i++)
		if(F[i]) return 1;
	return 0;
}
int main()
{
	F[0]=1; n=read(); k=read();
	for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+1+n);
	int ans=0;
	int l=1,r=n; while(l<=r)
	{
		int mid=(l+r)>>1;
		if(!check(mid)) ans=mid,l=mid+1;
		else r=mid-1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
class Point(object):
    __slots__ = ["x", "y"]

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __iter__(self):
        yield self.x
        yield self.y

    def __add__(self, other: "Point") -> "Point":
        return Point(self.x + other.x, self.y + other.y)

    def __sub__(self, other: "Point") -> "Point":
        return Point(self.x - other.x, self.y - other.y)

    def __mul__(self, s: int):
        return Point(self.x * s, self.y * s)

    def project(self, vector: "Vector") -> "Point":
        return (vector * (Vector(vector.p1, self).dot(vector) / vector.norm)).p2

    def reflect(self, vector: "Vector") -> "Point":
        return self + (self.project(vector) - self) * 2


class Vector(object):
    __slots__ = ["p1", "p2", "x", "y", "norm", "abs"]

    def __init__(self, p1: Point, p2: Point):
        self.p1 = p1
        self.p2 = p2
        self.x = p2.x - p1.x
        self.y = p2.y - p1.y
        self.norm = self.x ** 2 + self.y ** 2
        self.abs = abs(self.x + self.y)

    def __mul__(self, s):
        return Vector(self.p1, Point(self.p1.x + self.x * s, self.p1.y + self.y * s))

    def __lt__(self, other: "Vector"):
        return other.abs > self.abs

    def __gt__(self, other: "Vector"):
        return other.abs < self.abs

    def dot(self, other: "Vector"):
        return self.x * other.x + self.y * other.y

    def cross(self, other: "Vector"):
        return self.x * other.y - self.y * other.x


if __name__ == "__main__":
    x1, y1, x2, y2 = map(int, input().split())
    vector1 = Vector(Point(x1, y1), Point(x2, y2))
    for point in (Point(*map(int, input().split())) for _ in [0]*int(input())):
        print(*point.reflect(vector1))


Measured memory_bytes: 5796
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long ans = 0;
		if(a%2==0||b%2==0||c%2==0) ans = 0;
		else {
			ans = Math.min(c*Math.min(a,b),a*b);
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 9548
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    const int XMAX = 50;
    const int NMAX = 50;
    int N, A;  cin >> N >> A;
    vi X(N + 1, 0); 
    FOR(i, 1, N + 1) cin >> X[i];
    vi Y(N + 1, 0);
    FOR(i, 1, N + 1) Y[i] = X[i] - A;

    auto dp = vvl(NMAX + MGN, vl(2*XMAX*NMAX + MGN, 0));
    // dp[i][j] : The number of ways to choose whose sum is j from Y[1]..Y[i]

    dp[0][XMAX*NMAX] = 1;
    FOR(i, 1, N + 1) dp[i][XMAX*NMAX] = 1;

    FOR(i, 1, N + 1) {
        FOR(k, 0, 2*XMAX*NMAX + 1) {
            if (0<= k - Y[i] && k - Y[i] <= 2*XMAX*NMAX) {
                dp[i][k] = dp[i - 1][k] + dp[i - 1][k - Y[i]];
            } else {
                dp[i][k] = dp[i - 1][k];
            }
        }
    }

    ll ans = dp[N][XMAX*NMAX] - 1;

    cout << ans << endl;

    return 0;
}

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

int main()
{
    int n,ans;

    cin >> n;
    vector<vector<int>> g(n, vector<int>(n));
    rep(i, n) {
        rep(j, n) g[i][j] = -1;
        int a,x,y;
        cin >> a;
        rep(j, a) {
            cin >> x >> y;
            g[i][--x] = y;
        }
    }

    ans = 0;
    for (int bit = 0; bit < (1 << n); ++bit) {
        vector<int> d(n);
        int bitcount = 0;
        rep(i, n) {
            if ((bit >> i) & 1) {
                d[i] = 1;
                ++bitcount;
            }
        }
        bool ok = true;
        rep(i,n) {
            if (d[i]) {
                rep(j, n) {
                    if (g[i][j] == -1)
                        continue;
                    if (g[i][j] != d[j])
                        ok = false;
                }
            }
        }
        if (ok)
            ans = max(ans, bitcount);
    }

    std::cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map> 

#define debug printf("This is Debug")

using namespace std;

long long arr[200005];
long long sum[200005];

map<long long , long long>mp;

long long ans ;

int main(){
	
	int n;
	scanf("%d",&n);
	
	for(int i=1;i<=n;++i){
		scanf("%lld",&arr[i]);
	}
	
	sum[0] = 0;
	ans = 0;	
	mp.insert(pair<long long,long long>(0,1));
	
	long long x;
	map<long long ,long long>::iterator it;;
	for(int i=1;i<=n;++i){
		sum[i] = sum[i-1] + arr[i];
		
		it=mp.find(sum[i]);
  		if(it==mp.end()){
        	x = 0;
        	mp.insert(pair<long long,long long>(sum[i],1));
		}
  		else{
  			x = it->second;
  			mp.erase(it);
  			mp.insert(pair<long long,long long>(sum[i],x+1));
		}
		
		ans += x;
	//	cout<<x<<endl;
	//	mp.insert(pair<long long,long long>(sum[i],x+1));
	}
	
	printf("%lld\n",ans);


	return 0;
}


Measured memory_bytes: 15872
use std::cmp::max;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let (ga, sa, ba) = (sc.read(), sc.read(), sc.read());
    let (gb, sb, bb) = (sc.read(), sc.read(), sc.read());

    let first = dp(n, [(ga, gb), (sa, sb), (ba, bb)]);
    let first_max = first
        .into_iter()
        .enumerate()
        .map(|(i, v)| i + v)
        .max()
        .unwrap();
    let second = dp(first_max, [(gb, ga), (sb, sa), (bb, ba)]);
    let second_max = second
        .into_iter()
        .enumerate()
        .map(|(i, v)| i + v)
        .max()
        .unwrap();
    println!("{}", second_max);
}

fn dp(n: usize, trade: [(usize, usize); 3]) -> Vec<usize> {
    let mut dp = vec![0; n + 1];
    for i in (0..(n + 1)).rev() {
        for &(from, to) in trade.iter() {
            if i != n && dp[i] == 0 {
                continue;
            }
            if i >= from {
                dp[i - from] = max(dp[i - from], dp[i] + to);
            }
        }
    }
    dp
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 200956
require 'pp'
require 'set'

n = gets.chomp!.to_i
t, a = gets.chomp!.split(' ').map(&:to_i)
h_n = gets.chomp!.split(' ').map(&:to_i)

max = 10 ** 10
max_i = 0
h_n.each.with_index(1) do |h, i|
    temp = t - h * 0.006
    x = (a - temp).abs
    if x < max
        max = x
        max_i = i
    end
end

puts max_i


Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  deque<char> dq;

  // 1 -> 先頭に追加する。(push_front)
  // 2 -> 末尾に追加する。(push_back)

  bool flag = true; // trueのときは正常に操作を行う。
  bool flag2 = false; // 最後が1のとき

  string s;
  cin >> s;
  int q;
  repr(i, s.size(), 0) {
    dq.push_back(s[i]);
  }
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int query;
    cin >> query;
    if (query == 1) {
      flag = !flag;
    } else if (query == 2) {
      int a;
      char c;
      cin >> a >> c;
      if (flag) {
        if (a == 1) {
          dq.push_front(c);
        } else {
          dq.push_back(c);
        }
      } else {
        if (a == 1) {
          dq.push_back(c);
        } else {
          dq.push_front(c);
        }
      }
    }
  }

  if (flag) {
    for (auto it : dq) {
      cout << it;
    }
    cout << "\n";
  } else {
    reverse(dq.begin(), dq.end());
    for (auto it : dq) {
      cout << it;
    }
    cout << "\n";
  }

}

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




int N, M, cnt[101010];
//-----------------------------------------------------------------
int main() {
    cin >> N >> M;
    rep(i, 0, M) {
        int a, b; scanf("%d%d", &a, &b);
        cnt[a]++;
        cnt[b]++;
    }

    rep(i, 1, N + 1) if (cnt[i] % 2) {
        printf("NO\n");
        return 0;
    }

    printf("YES\n");
}

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

bool prime[1000001];

void is_prime(int n){
	for(int i = 0; i <= n; ++i)
		prime[i] = true;
		
	prime[0] = prime[1] = false;
	for(int i = 2; i <= n; ++i){
		if(prime[i]){
			for(int j = i * 2; j <= n; j += i)
				prime[j] = false;
		}
	}
}

int main() {
	is_prime(1000000);
	
	int a, d, n;
	while(cin >> a >> d >> n && (a || d || n)){
		int c = 0, sum = a;
		while(1){
			if(prime[sum])
				c++;
			if(c == n)
				break;
			sum += d;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 2136
import math


a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if a == b:
    print('YES')
    exit(0)

if v <= w:
    print('NO')
    exit(0)

if (v - w) * t >= abs(a - b) and abs(a - b) % math.gcd(v, w) == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 9192
N = int(input())
A_list = list(map(int, input().split()))

money = (1000, 0)
stock = (0, 0)

for A in A_list:
	mm = money
	ms = (money[0] % A, money[0] // A)
	sm = (stock[0] + stock[1] * A, 0)
	ss = (stock[0] % A, stock[1] + stock[0] // A)
	
	if mm[0] > sm[0] or (mm[0] == sm[0] and mm[1] > sm[1]):
		money = mm
	else:
		money = sm
	
	if ms[1] > ss[1] or (ms[1] == ss[1] and ms[0] > ss[0]):
		stock = ms
	else:
		stock = ss

print(money[0])


Measured memory_bytes: 9228
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<ll, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

int main(){
    int n;
    cin >> n;
    int p[n * 2];
    for(int i = 0 ; i < 2 * n ; i ++ )
        cin >> p[i];
    sort(p, p + 2 * n);
    int res = 0;
    for(int i = 0 ; i < 2 * n; i ++ ){
        if(i % 2 == 0)
            res += p[i];
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int  N=  sc.nextInt();
		int  K=  sc.nextInt();
		
		int ans = K;
		
		if(N == 1)
		{
			System.out.println(ans);
		}else 
		{
			for(int i = 1; i < N; i++)
			{
				ans =  ans * (K - 1);
			}
			
			System.out.println(ans);
		}
	}

}


Measured memory_bytes: 23764
#include <iostream>

int main()
{
    int a = 0;
    int b= 0;
    int total = 0;
    std::cin >> a >> b;
    long base = (a >= 2) ? (a*(a - 1)) / 2 : 0;
    long base2 = (b >= 2) ? (b*(b - 1)) / 2 : 0;
    std::cout << base+base2;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD=1e9+7;
const int MAX=1e5+100;

int main() {
  int N;cin>>N;
  string S,T;cin>>S>>T;
  string res;
  REP(i,N) {
    res.push_back(S[i]);
    res.push_back(T[i]);
  }
  OUT(res);

  return 0;
}


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

using namespace std;

typedef long long ll;

const ll inf = 1LL << 60;

int main(){
  int N; cin >> N;
 ll dp[100010];
 ll  h[100010];
  
  for(int i = 0; i < N; i++){ cin >> h[i];}
  
  for(int j = 0; j < 100010; j++){ dp[j] = inf;}
  
  dp[0] = 0;
  
  for(int i = 1; i < N; i++){
    dp[i] = min(dp[i],dp[ i - 1] + abs( h[i] - h[i-1]));
   if( i > 1) { dp[i] = min( dp[i], dp[i-2] + abs( h[i] - h[i-2]));}}
  
  cout << dp[N-1] << endl;
   return 0;}
  

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

int main(){
	int n,k;
	cin>>n>>k;
	int count=0;
	for(int i=0;i<k;i++){
		int x,ans=0;
		cin>>x;
		count+=x;

	}
	if(n-count>-1)	cout<<n-count<<endl;
	else cout<<-1<<endl;
	return 0;
	
}


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

int main()
{
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	int aa = 100 * a, bb = 100 * b;
	int r_num = 0, r_den = 1;
	int r_sugar = 0, r_sugarwater = aa;
	
	for(int ia=0; aa*ia<=f; ia++)
	{
		int r1 = f - aa*ia;
		for(int ib=0; bb*ib<=r1; ib++)
		{
			int r2 = r1 - bb*ib;
			for(int ic=0; c*ic<=r2; ic++)
			{
				int r3 = r2 - c*ic;
				for(int id=0; d*id<=r3; id++)
				{
					int water = aa*ia + bb*ib;
					int sugar_capacity = water / 100 * e;
					int sugar = c*ic + d*id;
					if(sugar <= sugar_capacity)
					{
						int x_num = sugar;
						int x_den = sugar + water;
						if(x_num*r_den > r_num*x_den)
						{
							r_num = x_num;
							r_den = x_den;
							r_sugar = sugar;
							r_sugarwater = sugar + water;
						}
					}
					
				}
			}
		}
	}
	cout << r_sugarwater << " " << r_sugar << endl;
	
	return 0;
}

Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import core.bitop;

  int n; rd(n);

  int k=1;
  while(k*2<=n) k*=2;

  writeln(max(popcnt(n), popcnt(k-1)));
}


void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}



Measured memory_bytes: 2480
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: i64 = s.next().unwrap().parse().unwrap();
	let s: i64 = s.next().unwrap().parse().unwrap();

	let ans = calc(n, s);
	println!("{}", ans);
}

fn calc(n: i64, s: i64) -> i64 {

	if n > s {
		for d in divisors(n - s) {
			let b = d + 1;
			if f(b, n) == s {
				return b;
			}
		}
	}
	if n == s {
		return n + 1;
	}

	-1
}

fn f(b: i64, mut n: i64) -> i64 {
	let mut r = 0;
	while n > 0 {
		r += n % b;
		n /= b;
	}
	r
}

pub fn divisors<T>(n: T) -> impl std::iter::Iterator<Item = T>
where
	T: num::PrimInt,
{
	let n = if n < T::zero() { T::zero() - n } else { n };
	let mut d = T::one();
	let mut divs = vec![];
	std::iter::from_fn(move || {
		while d * d <= n {
			if n % d == T::zero() {
				let r = d;
				if d != n / d {
					divs.push(n / d);
				}
				d = d + T::one();
				return Some(r);
			}
			d = d + T::one();
		}

		divs.pop()
	})
}


Measured memory_bytes: 2136
#include<iostream>
#include<string>

using namespace std;

int checkNum(string s){
    if(s == "AC"){
        return 0;
    } else if(s == "WA"){
        return 1;
    } else if(s == "TLE"){
        return 2;
    } else if(s == "RE"){
        return 3;
    }
    return 4;
}

int main(){
    int n;
    cin >> n;
    int ans[5] = {0};
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        ans[checkNum(s)] += 1;
    }
    cout << "AC x " << ans[0] << endl;
    cout << "WA x " << ans[1] << endl;
    cout << "TLE x " << ans[2] << endl;
    cout << "RE x " << ans[3] << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main(){
    ll n,k; cin >> n >> k;

    cout << n-k+1 << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val lList = readLine()!!.split(' ').map(String::toLong).sortedDescending()
    val lIndex = Array(lList[0].toInt() + 1) { 0 }
    for (i in 0 until n) {
        val l = lList[i]
        for(j in 0..l){
            lIndex[j.toInt()] = i
        }
    }
    var count = 0L
    for (first in 0..(n - 3)) {
        for (second in (first + 1)..(n - 2)) {
            val thirdMinLength = lList[first] - lList[second] + 1
            val p = Math.max(0,lIndex[thirdMinLength.toInt()] - second)
            count += p
        }
    }
    println(count)
}

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

typedef long long ll;
#define F(n) for(int i = 0; i < n; i++);
#define FI(n) for(int i = 0; i <= n; i++);
#define FS(a, n) for(int i = a; i < n; i++);
#define vi vector<int>;
#define vl vector<long int>;
#define vll vector<long long>;

int main() {

    ios_base:: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string a;
    string b;
    cin >> a >> b;
    int n = a.size();
    int m = b.size();

    int dp[n + 1][m + 1];
    memset(dp, 0, sizeof(dp));

    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= m; j++) {
            if(i == 0 || j == 0) {
                dp[i][j] = 0;
            }
            else if(a[i - 1] == b[j - 1]){
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    // for(int i = 0; i < n + 1; i++) {
    //     for(int j = 0; j < m + 1; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    int  i = n;
    int j = m;
    string ans = "";
    while(i > 0 && j > 0) {
        if(a[i - 1] == b[j - 1]) {
            ans = ans + a[i - 1];
            i--;
            j--;
        }
        else if(dp[i][j - 1] > dp[i - 1][j] ) { 
            j--;
        }
        else {
            i--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 35456
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;

ll n;
int main(){
	scanf("%lld",&n);
	ll sum = 0;
	for(int i=1;i<n;i++) sum += i;
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val num        = io.StdIn.readInt
    var prime_nums = Vector.empty[Int]

    (2 to num).foreach { i =>
      var flag = true
      (2 to Math.sqrt(i).toInt).foreach { j =>
        if(i%j == 0) flag = false
      }

      if(flag) prime_nums = prime_nums :+ i
    }
    
    var prime_flag = false
    var next_num = num

    if(prime_nums.last != num) {
      while(!prime_flag) {
        next_num += 1
        var flag = false
        prime_nums.foreach { i =>
          if(next_num%i == 0) flag = true
        }
        
        if(!flag) prime_flag = true
      }
    }

    println(next_num)
  }
}

Measured memory_bytes: 35104
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextInt()){
			int N = sc.nextInt();
			int[] n = new int[N];

			for(int i = 0; i < N; i++)
				n[i] = sc.nextInt()*60 + sc.nextInt();

			int M = sc.nextInt();
			int[] m = new int[M];

			for(int i = 0; i < M; i++)
				m[i] = sc.nextInt()*60 + sc.nextInt();

			int[] nm = new int[N+M];
			for(int i = 0; i < N; i++)
				nm[i] = n[i];
			for(int i = 0 ; i < M; i++)
				nm[N+i] = m[i];
			Arrays.sort(nm);
			int count=0;
			for(int i=1;i<nm.length;i++){
				if((nm[i]==nm[i-1])){
					nm[i-1]=0;count++;
				}

			}
			Arrays.sort(nm);
			for(;count < N+M; count++){
				System.out.printf("%d:%02d",nm[count]/60, nm[count]%60);
			if(!(count == N+M-1))
				System.out.print(" ");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 20948
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		for (int i = 0; i < N; ++i) {		
			BigInteger n = sc.nextBigInteger();
			BigInteger m = sc.nextBigInteger();
			BigInteger MAX = new BigInteger("100000000000000000000000000000000000000000000000000000000000000000000000000000000");
			if (n.add(m).compareTo(MAX) < 0) {
				System.out.println(n.add(m));
			} else {
				System.out.println("overflow");
			}
		}
	}
}

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

int main(){
  int l,r,d;
  cin>>l>>r>>d;
  int cnt=0;
  for(int i=l;i<=r;i++){
    if(i%d==0) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3592
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <algorithm>
#include <cmath>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define REP(i, n) for(int i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()

using namespace std;


class CStrangeBank {
public:
    ll N;
    vector<ll> t = vector<ll>(100001, -1);

    void solve(std::istream& in, std::ostream& out) {
        in >> N;
        out << dfs(N) << endl;
    }

    ll dfs(int n) {
        if (n < 0) return 100000;
        if (t[n] != -1) return t[n];
        ll m = n;
        for (int i = 1; pow(9, i) <= N; ++i) {
            m = min(m, dfs(n - pow(9, i)) + 1);
        }
        for (int i = 1; pow(6, i) <= N; ++i) {
            m = min(m, dfs(n - pow(6, i)) + 1);
        }
        t[n] = m; return m;
    }
};


int main() {
    CStrangeBank solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3072
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

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

    string s;
    cin >> s;

    int ans = 0;
    int x = 0;
    for(char c : s){
        if(c == 'I'){
            x++;
        }else{
            x--;
        }
        ans = max(ans, x);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 632
def ap(i):
    if len(root)<i:
        for _ in range(i-len(root)):root.append(0)
    root[i-1]=[0,1][root[i-1]==0]
while 1:
    try:
        root=[0,0]
        while 1:
            n,m=map(int,input().split())
            if n==m==0:break
            ap(n)
            ap(m)
        if root.pop(0)+root.pop(0)==2 and sum(root)==0:print("OK")
        else:print("NG")
    except:break


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" a : "<<a<<"\n"
#define debug2(a,b) cout<<" a : "<<a<<" b : "<<b<<"\n"
#define debug3(a,b,c) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<" d : "<<d<<"\n"
// #define M 421412341324321
#define MOD 998244353 


signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	string s, t;
	cin>>s>>t;

	vector <set <int>> v(26);
	rep(i,s.length())
	{
		int x = s[i]-'a';
		v[x].insert(i+1);
	}
	int pre = 0, ans = 0, curr=0;
	rep(i,t.length())
	{
		int x = t[i]-'a';
		if (sz(v[x])==0)
		{
			cout<<-1;
			return 0;
		}
		auto itr = v[x].upper_bound(pre);
		if (itr==v[x].end())
		{
			ans+=sz(s)-pre;
			pre = 0;
            itr = v[x].begin();
		}
		curr = *itr;
		ans+=curr-pre;
		pre = curr;
	}
	cout<<ans;

	return 0;
}



Measured memory_bytes: 5200
#include<iostream>
#include<cmath>
#include<cstdio>
#include<iomanip>
using namespace std;
#pragma warning(disable:4996)
struct Point { long double px, py; };
struct Segment { Point p1, p2; };
Point X[200000];
Point Minus(Point a, Point b) { Point G; G.px = a.px - b.px; G.py = a.py - b.py; return G; }
long double Abs(Point a) { return sqrt(a.px*a.px + a.py*a.py); }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
long double dst(const Segment& a, const Point& b) {
	return abs(crs(Minus(a.p2, a.p1), Minus(b, a.p1)) / Abs(Minus(a.p2, a.p1)));
}
int main() {
	int N = 0;
	while (scanf("%Lf,%Lf", &X[N].px, &X[N].py) != EOF) {
		N++;
	}
	long double SUM = 0.0l;
	for (int i = 1; i < N - 1; i++) {
		Segment A; A.p1 = X[i]; A.p2 = X[i + 1];
		long double DST = dst(A, X[0]);
		Point H; H.px = X[i].px - X[i + 1].px;
		H.py = X[i].py - X[i + 1].py;
		long double LEN = Abs(H);
		SUM += DST*LEN / 2;
	}
	cout << fixed << setprecision(1919) << SUM << endl;
	return 0;
}

Measured memory_bytes: 1304
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <math.h>
#include <algorithm>

using namespace std;

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

    int n;
    int *S;
    int q;
    int *T;
    int C=0;
    
    scanf("%d", &n);
    S = (int*)calloc(n, sizeof(int));
    for (int i = 0; i < n; i++) {
	scanf("%d", &S[i]);
    }

    scanf("%d", &q);
    T = (int*)calloc(q, sizeof(int));
    for (int i = 0; i < q; i++) {
	scanf("%d", &T[i]);
    }

    for (int i = 0; i < q; i++) {
	for (int j = 0; j < n; j++) {
	    if (S[j] == T[i]) {
		C++;
		break;
	    }
	}
    }

    printf("%d\n", C);

    return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	set<int> st;
	for (int i = 0; i < k; ++ i) {
		int d;
		cin >> d;
		while (d --) {
			int x;
			cin >> x;
			st.insert(x);
		}
	}
	cout << n - st.size();
	
}

Measured memory_bytes: 3648
def check(learn_total):
    for i in range(m):
        if learn_total[i] < x:
            return False
    return True


def calc_price(bit):
    price_total = 0  # 値段の合計
    learn_total = [0] * m  # 理解度

    for i in range(n):
        if (bit >> i) & 1:  # i桁目が0か1か見て、i番目を買うか買わないか判定します
            price_total += c[i]  # 買うので、i番目の値段を加算します
            learn = a[i]  # 「i番目の参考書を読んで増える、各アルゴリズムの理解度」のリストです
            for j, le in enumerate(learn):  # 理解度を足します。 enumerateを使うと、range(n)よりスマートです
                learn_total[j] += le

    # 条件を満たすか、check関数で確認します
    if check(learn_total):
        return price_total
    else:
        return INF


if __name__ == '__main__':
    INF = float("inf")

    n, m, x = list(map(int, input().split()))

    # 空のリストを作って、appendで追加していきます
    c = []  # 参考書の値段です
    a = []  # 各参考書に入る理解度です

    for i in range(n):
        c_temp, *a_temp = list(map(int, input().split()))  # こうすると、2つ目以降をリストで受け取れます
        c.append(c_temp)
        a.append(a_temp)

    ans = INF

    for bit in range(1 << n):
        price = calc_price(bit)  # 条件を満たすなら価格、満たさないならINFが返ってきます
        ans = min(ans, price)  # 答えを更新します

    if ans == INF:
        print(-1)
    else:
        print(ans)


Measured memory_bytes: 9164
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0 ; i < int(N);i++)
using namespace std ;
typedef long long ll;
typedef pair <int , int >pi;
typedef vector <int> vi ;
typedef vector <string> si;



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

    string d;
    int count = 0 ;
    cin >> d;
    if (d[1] == 'S' && d[0] == 'R' && d[2] == 'R'){
    	cout << 1;
    	return 0;
    }
    for (int i = 0 ; i < 3 ; i++){
    	if (d[i] == 'R'){
    		count++;
    	}

    }
  	cout << count;
    

	return 0 ;
}

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

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

  std::string S;
  std::cin >> S;
  for(int i = 0;i < S.length();i++)
  {
    if(i % 2 == 0) std::cout << S[i];
  }
  std::cout << '\n';
}


Measured memory_bytes: 592
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

LL r, d, x[15];

int main(){
    cin >> r >> d >> x[0];
    for(int i = 1;i <= 10;i++){
        x[i] = r*x[i - 1] - d;
        cout << x[i] << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    int n;
    cin >> n;
    cout << ( 1 + n ) * n / 2 << endl;
    return 0;
}

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

#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long int lld;
typedef pair<lld, lld> pii;

const int MAXN = 100002;

int n, m;
int p[MAXN];
vector <int> adj[MAXN];

void bfs() {
    fill(p + 1, p + n + 1, -1);
    int nodo = 1;
    p[nodo] = 0;
    queue <int> cola;
    cola.push(nodo);
    while (!cola.empty()) {
        nodo = cola.front();
        cola.pop();
        for (int v : adj[nodo]) {
            if (p[v] != -1) continue;
            p[v] = nodo;
            cola.push(v);
        }
    }
}

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

    cin >> n >> m;

    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    bfs();

    bool posible = true;
    for (int i = 1; i <= n; ++i) {
        if (p[i] == -1)
            posible = false;
    }

    if (posible) {
        cout << "Yes\n";
        for (int i = 2; i <= n; ++i) {
            cout << p[i] << "\n";
        }
    } else {
        cout << "No\n";
    }

    return 0;
}

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

using namespace std;

void solve(string S) {
  long b = 0;
  long ans = 0;
  rep(i, S.length()) {
    if (S[i] == 'W')
      ans += b;
    else
      b++;
  }
  cout << ans << endl;
}

int main(){
  // int 3E4
  // long 2E9
  // long long 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  string S;
  cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 788
#include <bits/stdc++.h> 
#define MOD 1000000007
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
      #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    ull t;
    cin >> t;
    ull count = 100;
    ull years = 0;
    while(count<t){
        count = count + count/100;
        years++; 
    } 
    cout << years << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
         Scanner in=new Scanner(System.in);
         int a=in.nextInt();
         int b=in.nextInt();
         int c=in.nextInt();
         if((a==5 && b==5)||(b==5 && c==5)||(a==5 && c==5)){
             System.out.println("YES");
         }else{
             System.out.println("NO");
         }
    }
}

Measured memory_bytes: 23764
#include <iomanip>
#include <utility>
#include <algorithm>
#include <type_traits>
#include <set>
#include <string>
#include <iostream>
#include <fstream>
#include <cassert>
#include <memory>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <queue>
#include <vector>
#include <array>
#include <chrono>
#include <random>
#include <forward_list>
#include <iomanip>
#include <functional>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <sstream>
#include <numeric>

using namespace std;
#define MFOR(i,end) for(size_t i = 0, end_i = (end); i < end_i; ++ i)


int main()
{
	int a[3];
	std::cin >> a[0] >> a[1] >> a[2];
	int* max_ = std::max_element(a,a+3);
	if ((*max_) * 2 == a[0] + a[1] + a[2]) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
}

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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    if(n <= 111) ans = 111;
    else if(n > 111 && n <= 222) ans = 222;
    else if(n > 222 && n <= 333) ans = 333;
    else if(n > 333 && n <= 444) ans = 444;
    else if(n > 444 && n <= 555) ans = 555;
    else if(n > 555 && n <= 666) ans = 666;
    else if(n > 666 && n <= 777) ans = 777;
    else if(n > 777 && n <= 888) ans = 888;
    else if(n > 888 && n <= 999) ans = 999;
    cout << ans << endl;
    return 0;
}

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

//型定義
typedef long long ll;

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

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

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

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

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=a*c;
    ans=max(ans,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout<<ans<<endl;
    
}

Measured memory_bytes: 3636
#include <iostream>
int main() {
    int a, b;
    char op;
    for (std::cin >> a >> op >> b; op != '?'; std::cin >> a >> op >> b) {
        if (op == '+') {
            a += b;
        } else if (op == '-') {
            a -= b;
        } else if (op == '*') {
            a *= b;
        } else {
            a /= b;
        }
        std::cout << a << std::endl;
    }
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main(){
	scanf("%lld%lld%lld",&a,&b,&c);
	for(int i=0;i<=1000000;i++){
		if((a&1)|(b&1)|(c&1)){
			printf("%d\n",i);
			exit(0);
		}
		long long x=(a+b)/2,y=(a+c)/2,z=(b+c)/2;
		a=x,b=y,c=z;
	}
	printf("%d\n",-1);
} 

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

int main()
{
	bool flag = true;
	int N; cin >> N;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		string s; cin >> s;
		if (s == "A")cnt++;
		else cnt--;

		if (cnt < 0)flag = false;
	}
	if (cnt != 0)flag = false;

	cout << (flag ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 3148
n = int(input())
cnt = [0, 0, 0, 0]
for i in range(n):
    s = input()
    if s == "AC":
        cnt[0] += 1
    elif s == "WA":
        cnt[1] += 1
    elif s == "TLE":
        cnt[2] += 1
    elif s == "RE":
        cnt[3] += 1

print("AC x {}".format(cnt[0]))
print("WA x {}".format(cnt[1]))
print("TLE x {}".format(cnt[2]))
print("RE x {}".format(cnt[3]))

Measured memory_bytes: 9224