akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
    int A,B,max;
    int c=0;
    scanf("%d %d",&A ,&B);
    if(A>=B){
        max=A;
    }
    else{
        max=B;
    }
    for(int i=1;i<max;i++){
        if((A-i)==(B-i)||(i-A)==(i-B)||(i-A)==(B-i)||(A-i)==(i-B)){
                c=i;
                break;
        }
    }
    if(c==0){
        printf("IMPOSSIBLE\n");
    }
    else{
        printf("%d\n",c);
    }
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

from collections import defaultdict

D = defaultdict(int)

res = 0

for i in range(N):
    D[A[i]] += 1

for k, v in D.items():
    res += k * v

for _ in range(Q):
    b, c = map(int, input().split())
    p = D[b]
    D[b] = 0
    D[c] += p
    res -= b * p
    res += c * p
    print(res)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll K;
  IN(K);
  ll X, Y;
  IN(X,Y);

  ll signx = 1;
  if(X<0) signx = -1;
  X = abs(X);
  ll signy = 1;
  if(Y<0) signy = -1;
  Y = abs(Y);

  ll D = X+Y;

  if(K%2==0 && D%2==1){
    OUT(-1);
    return 0;
  }

  vll ansx, ansy;

  ll x = X%K;
  ll y = Y%K;
  if(x+y<K){
    if(x<X) x += K;
    else if(y<Y) y += K;
  }
  if((x+y)%K==0){
    if(x!=0 || y!=0){
      ansx.pb(x);
      ansy.pb(y);
    }
  }else if((x+y)%2==1){
    if(x<K){
      ansx.pb(x);
      ansy.pb(K-x);
      ll mid = (y+(K-x))/2;
      ll diff = abs(mid-y);
      ansx.pb(x+K-diff);
      ansy.pb(mid);
    }else{
      ansx.pb(K-y);
      ansy.pb(y);
      ll mid = (x+(K-y))/2;
      ll diff = abs(mid-x);
      ansx.pb(mid);
      ansy.pb(y+K-diff);
    }
    ansx.pb(x);
    ansy.pb(y);
  }else{
    ll mid = (x+y)/2;
    if(x>=y){
      ansx.pb(mid);
      ansy.pb(-(K-mid));
    }else{
      ansx.pb(-(K-mid));
      ansy.pb(mid);
    }
    ansx.pb(x);
    ansy.pb(y);
  }

  while(x+K<=X){
    x += K;
    ansx.pb(x);
    ansy.pb(y);
  }
  if(y<Y){
    ll tmp = abs(X-x);
    x += tmp;
    y += K-tmp;
    ansx.pb(x);
    ansy.pb(y);
    while(y+K<=Y){
      y += K;
      ansx.pb(X);
      ansy.pb(y);
    }
  }

  printf("%lld\n", ansx.size());
  REP(i,ansx.size()){
    printf("%lld %lld\n", signx*ansx[i], signy*ansy[i]);
  }

  /*
  printf("Dist:\n");
  ll dist = abs(ansx[0]) + abs(ansy[0]);
  printf("%lld %lld\n", 0, dist);
  REP(i,ansx.size()-1){
    dist = abs(ansx[i]-ansx[i+1]) + abs(ansy[i]-ansy[i+1]);
    printf("%lld %lld\n", i+1, dist);
  }
  */

  return 0;
}

Measured memory_bytes: 5604
#include<bits/stdc++.h> 
using namespace std; 
typedef long long ll;
int n,m,q,a[55],b[55],c[55],d[55],ans,aa[55];
void Calc(){
	int s=0;
	for(int i=1;i<=q;i++)if(aa[b[i]]-aa[a[i]]==c[i])s+=d[i];
	ans=max(ans,s);
}
void DFS(int x){
	if(x>n){
		Calc();
		return ;
	}
	for(int i=max(aa[x-1],1);i<=m;i++)aa[x]=i,DFS(x+1);
}
int main(){
	cin>>n>>m>>q;
	for(int i=1;i<=q;i++)cin>>a[i]>>b[i]>>c[i]>>d[i];
	DFS(1);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)
#define revrep(i,N) for(int i=N-1; i>=0; i--)
#define coutline cout<<"------------ ("<<__LINE__<<")"<<endl;

typedef long long ll;

ll gcd(ll a, ll b);
ll gcd_r(const vector<ll> &v, vector<ll> &buf, const int idx);
ll gcd_l(const vector<ll> &v, vector<ll> &buf, const int idx);

int main(void)
{

    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) {
        cin >> A.at(i);
    }

    vector<ll> m(N);
    vector<ll> buf_r(N,-1);
    vector<ll> buf_l(N,-1);
    rep(ignore,N) {
        ll r = gcd_r(A, buf_r, ignore-1);
        ll l = gcd_l(A, buf_l, ignore+1);
        m.at(ignore) = gcd(min(r,l),max(r,l));
    }

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

    cout << *(m.end()-1) << endl;

    return 0;
}

/* _a < _b */
ll gcd(ll a, ll b)
{
    if (a == 0) return b;

    ll c = b % a;
    return gcd(c, a);
}

/* buf should be initialize to -1 */
ll gcd_r(const vector<ll> &v, vector<ll> &buf, const int idx)
{
    if (idx < 0) {
        return 0;
    } else if (buf.at(idx) != -1) {
        return buf.at(idx);
    }  else if (idx == 1) {
        return gcd(min(v.at(0),v.at(1)), max(v.at(0),v.at(1)));
    } else {
        ll a = gcd_r(v, buf, idx-1);
        buf.at(idx) = gcd(min(a,v.at(idx)), max(a,v.at(idx)));
        return buf.at(idx);
    }
}

/* buf should be initialize to -1 */
ll gcd_l(const vector<ll> &v, vector<ll> &buf, const int idx)
{
    if (idx >= v.size()) {
        return 0;
    } else if (buf.at(idx) != -1) {
        return buf.at(idx);
    } else if (idx == v.size()-2) {
        return gcd(min(v.at(idx),v.at(v.size()-1)), max(v.at(idx),v.at(v.size()-1)));
    } else {
        ll a = gcd_l(v, buf, idx+1);
        buf.at(idx) = gcd(min(a,v.at(idx)), max(a,v.at(idx)));
        return buf.at(idx);
    }
}



Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int n,m;
  while(cin >> n >> m,n||m){
    int i,j,k;
    P p[m];
    for(j=0;j<m;j++){
      p[j].first=0;
      p[j].second=-(j+1);
    }
    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
	cin >> k;
	p[j].first+=k;
      }
    }
    sort(p,p+m,greater<P>());
    for(j=0;j<m;j++){
      cout << -p[j].second << (j==m-1?"\n":" ");
    }
  }
  return 0;
}

Measured memory_bytes: 1164
s=input()
l1=[]
l2=[]
num1=0 #0は反転なし　1はあり
def ap1(str1):
    l1.append(str1)
def ap2(str2):
    l2.append(str2)
nq=int(input())
for i in range(nq):
    q=list(input().split())
    if q[0]=="1":
        num1=(num1+1)%2
    else:
        f=int(q[1])
        if (num1+f)%2==1: #1で先頭 2で末尾
            ap1(q[2])
        else:
            ap2(q[2])
if num1==0:
    ans=""
    for i in range(len(l1)):
        ans+=l1[-1-i]
    ans+=s
    for i in range(len(l2)):
        ans+=l2[i]
else:
    ans=""
    for i in range(len(l2)):
        ans+=l2[-1-i]
    for i in range(len(s)):
        ans+=s[-1-i]
    for i in range(len(l1)):
        ans+=l1[i]
print(ans)


Measured memory_bytes: 11484
import Data.List

main = interact $ unlines . map (show . mazes) . read' . lines
 where
  read' ("0 0":_) = []
  read' (wh:xs) = ((w,h),m) : read' xs'
   where
    [w,h] = map read (words wh)
    (m,xs') = splitAt (2*h-1) xs

mazes ((w,h),m) = bfs (2*(w-1),2*(h-1)) m 1 u [(0,0)]
 where u = tail [(x,y) | x<-[0,2..2*(w-1)], y<-[0,2..2*(h-1)]]

bfs e m s u c 
 | elem e c = s
 | null c = 0
 | otherwise = bfs e m (s+1) (u \\ c') c'
 where
  c' = intersect (nub (concatMap neighbor c)) u
  neighbor (x,y) = map snd (filter movable dir)
   where 
    movable ((wx,wy),(x',y')) = elem (x',y') u && m!!wy!!wx == '0'
    dir = [((x-1,y),(x-2,y)),((x+1,y),(x+2,y)),((x,y-1),(x,y-2)),((x,y+1),(x,y+2))]

Measured memory_bytes: 5488
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int [] Pnums = Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToArray();
            int [] Qnums = Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToArray();
            List<int[]> list = Enumerate(Enumerable.Range(1, N)).ToList();

            int POrder = list.FindIndex(x => x.SequenceEqual(Pnums));
            int QOrder = list.FindIndex(x => x.SequenceEqual(Qnums));

            Console.WriteLine(Math.Abs(POrder - QOrder));
        }

        

        public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items)
        {
            if (items.Count() == 1)
            {
                yield return new T[] { items.First() };
                yield break;
            }
            foreach (var item in items)
            {
                var leftside = new T[] { item };
                var unused = items.Except(leftside);
                foreach (var rightside in Enumerate(unused))
                {
                    yield return leftside.Concat(rightside).ToArray();
                }
            }
        }
    }
}


Measured memory_bytes: 25416
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    map<int, int> cnt0, cnt1;
    REP(i,n){
        if (i % 2 == 0) cnt0[in()]++;
        else cnt1[in()]++;
    }

    int p = (n + 1) / 2, q = n/2;
    vector<P> a(2), b(2);
    for (P p : cnt0) a.push_back(P(p.second, p.first));
    for (P p : cnt1) b.push_back(P(p.second, p.first));
    sort(ALL(a));
    reverse(ALL(a));
    sort(ALL(b));
    reverse(ALL(b));
    int ans = n;
    REP(i,3) REP(j,3){
        if (a[i].second == b[j].second) continue;
        ans = min(ans, n - a[i].first - b[j].first);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6136
program main
integer :: k,a,b
logical :: ans = .false.

read(*,*)k
read(*,*)a,b

do i = a,b
if (mod(i,k) == 0) ans=.true.
end do

if (ans) then
write(*,*)'OK'
else
write(*,*)'NG'
end if
end program main

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

int ans, len;
char s[100005];

int main() {
    scanf("%s", s + 1);
    len = strlen(s + 1);
    for ( int i = 2; i <= len; i++ ) {
        if ( s[i] != s[i - 1] ) ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3864
#include <iostream>
using namespace std;
int main()
{
    int a, b, c, d, e, f, ans = 0;
    cin >> a >> b >> c;
    if(a == b && b == c){
        cout << (a % 2 == 0 ? -1 : 0) << endl;
        return 0;
    }
    while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
        d = a;
        e = b;
        f = c;
        a = (e + f) / 2;
        b = (d + f) / 2;
        c = (d + e) / 2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

#define MAX 2000000
#define INFTY (1 << 30)

int H,A[MAX+1];

void maxHeapfy(int i){
 int l,r,largest;
 l = 2*i;
 r = 2*i+1;

 if(l <= H && A[l] > A[i])largest = l;
 else largest = i;
 if(r <= H && A[r] > A[largest])largest = r;

 if(largest != i){
   swap(A[i],A[largest]);
   maxHeapfy(largest);
 }
}

int extract(){
  int maxv;
  if(H < 1) return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapfy(1);
  return maxv;
}

void increaseKey(int i,int key){
  if(key < A[i])return;
  A[i]=key;
  while(i>1 && A[i/2] < A[i]){
    swap(A[i],A[i/2]);
    i = i/2;
  }
}

void insert(int key){
  H++;
  A[H]= -INFTY;
  increaseKey(H,key);
}

int main(){
  int key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[0]=='e' && com[1]=='n')break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }else{
      printf("%d\n",extract());
    }
  }
  return 0;
}



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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
int T,A,B;
int i,a;
int main(){
    scanf("%d%d%d", &A, &B,&T);
    while(A<=T){
        a += B;
        T -= A;
    }
    printf("%d",a);
    return 0;
}

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

using ll = long long;
#define int ll

const int nax = 1e5 + 5;
vector<int> edges[nax];
int in_degree[nax];
int dist[nax];
bool visited[nax];

void dfs(int a)
{
	assert(!visited[a]);
	visited[a] = true;
	for(int b : edges[a])
	{
		dist[b] = max(dist[b],dist[a] + 1);
		in_degree[b]--;
		if(in_degree[b] == 0)
		{
			dfs(b);
		}
	}
}

int32_t main()
{
	int n,m;
	scanf("%lld%lld",&n,&m);
	while(m--)
	{
		int a,b;
		scanf("%lld%lld",&a,&b);
		edges[a].push_back(b);
		in_degree[b]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(!visited[i] && in_degree[i] == 0)
		{
			dfs(i);
		}
	}
	int answer = 0;
	for(int i=1;i<=n;i++)
	{
		answer = max(answer,dist[i]);
	}
	printf("%lld\n",answer);
	return 0;
}


Measured memory_bytes: 10496
#include<stdio.h>
int main(void){
	int a[5];
	int i,j,tmp;
	for(i=0;i<5;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<4;i++){
		for(j=4;j>i;j--){
			
			if(a[j]>a[j-1]){
				tmp=a[j];
				a[j]=a[j-1];
				a[j-1]=tmp;
			}
		}
	}
	printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);
	return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n,num,min,max;
		long sum = 0;
		n = sc.nextInt();
		num = sc.nextInt();
		min = num;
		max = num;
		sum += num;
		for(int i=1; i<n; i++) {
			num = sc.nextInt();
			min = Math.min(min, num);
			max = Math.max(max, num);
			sum += num;
		}
		System.out.println(min + " " + max + " " + sum);
	}
}

Measured memory_bytes: 31748
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    string s, t;
    cin >> s >> t;
    bool flag = false;
    for (unsigned int i = 0; i < s.size(); i++){
        if (s == t){
            flag = true;
            break;
        }
        rotate(s.begin(), s.end()-1, s.end());
    }
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

    static int N;
    static int M;
    static int Q;
    static int A;
    static long B;
    static long C;
    //    static int[][] map;
    static int min = 9999999;


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

        
        N = scanner.nextInt();
        M = scanner.nextInt();
        Q = scanner.nextInt();
        int[][] map  = new int[N][N];

        for (int i = 0; i < M; i++) {
            int a = scanner.nextInt() - 1;
            int b = scanner.nextInt() - 1;
            map[a][b]++;
        }

        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                map[i][j] += map[i][j - 1];
            }
        }
        for (int i = 0; i < N; i++) {
            for (int j = N - 2; j >= 0 ; j--) {
                map[j][i] += map[j + 1][i];
            }
        }
//
//        System.out.println();
//
//        for (int i = 0; i < N; i++) {
//            for (int j = 0; j < N; j++) {
//                System.out.print(map[i][j]);
//            }
//            System.out.println();
//        }

        for (int i = 0; i < Q; i++) {
            int a = scanner.nextInt() - 1;
            int b = scanner.nextInt() - 1;

            System.out.println(map[a][b]);
        }

        

    }
}



Measured memory_bytes: 153984
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/

int main(){
  ll N; cin >> N;
  ll ans = 0;
  for(ll i=1;i<=N;i++){
      ll y = N / i;
      ans+=y*(y+1)*i/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	Rapid_pleaseAC_fast;

	ic_a;
	ic_b;
	int x ;
	cin >> x;
	YES(a+b >= x&&a<=x);

	please AC;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <cstdlib>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include <iomanip>
#include<stack>
#include <unordered_map>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
// #define pi acos(-1)
// #include<bits/stdc++.h>
typedef long long ll;
#define INF 0x7f7f7f7f //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
#define STDIN freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
#define Quick ios::sync_with_stdio(false);cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m,n) for (int i = m;  i < n; i++)
#define PII pair<int,int>
#define PLL pair<long, long>
#define lowbit(x) (x&-x)

const int maxn = 50;
#define ERR 1e-6
#define fabs(a) (a < 0 ? -(a) : a)
#define square(a) ((a) * (a))

const int N = 2e5 + 10;
int a[N];
int d[N];
int main()
{
    //STDIN
    int k, n;
    cin >> k >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    for (int i = 1; i < n; i++)
    {
        d[i] = a[i]-a[i-1];
    }
    //cout << a[n-1] << " " << a[1] << endl;
    d[1] =k - (a[n-1]-a[0]);
    //cout << d[1] << endl;
    sort(d, d + n);
    //cout << d[n-1] << endl;
    cout << k - d[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> v(N+1);
  rep(i,N)cin >> v[i+1];
  int count = 0;
  rep(i,N){
    if(v[v[i+1]] == i+1)++count;
  }
  cout << count/2 << endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#define rep(i,n) for(i=0; i<n; i++)

int main(void){
	int n, r, m;
	scanf("%d%d", &n, &r);
	m=r+100*(10-n);
	if(n >= 10){
		printf("%d\n", r);
	}else{
		printf("%d", m);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <ctime>

#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL)
#define TT int test_cases; cin >> test_cases; while(test_cases--)
#define TT1 int test_cases=1; while(test_cases--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
using namespace std;
typedef long long int ll;

 
int main() {
    
    FAST;
    TT1{
        
        int n;cin>>n;
        vector<int> a(n);
        for(int i=0;i<n;i++) cin>>a[i];
        ll sum=0;
        for(int i=1;i<n;i++)
        {
            int d=max(a[i-1]-a[i],0);
            a[i]=a[i]+d;
            sum=sum+ll(d);
            
        }
        cout<<sum<<"\n";
    }
}

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

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

  int ans = 0;
  for (int i = 0; i < 2; i++) {
    if (A - B > 0) {
      ans += A;
      A--;
    }
    else {
      ans += B;
      B--;
    }
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

#define INPUT_NUM_MAX 100
#define INPUT_LENGTH_MAX 4



struct SCard {
	char pattern[2];
	int number;
	int originIndex;

	SCard() :pattern{"0"}, number(0), originIndex(0)
	{}
};

// 前方宣言
void BubbleSort(SCard* array, int arraySize, const char originalInput[][INPUT_LENGTH_MAX]);
void SelectionSort(SCard* cardArray, int arraySize, const char originalInput[][INPUT_LENGTH_MAX]);

int main()
{
	int inputNum = 0;

	scanf("%d", &inputNum);


	char Array[INPUT_NUM_MAX][INPUT_LENGTH_MAX] ;
	for (int i = 0; i < inputNum; i++) {
		scanf("%s", Array[i], INPUT_LENGTH_MAX);
	}

	SCard card1[INPUT_NUM_MAX];
	SCard card2[INPUT_NUM_MAX];

	for (int i = 0; i < inputNum; i++) {
		strncpy(card1[i].pattern, Array[i], 1); //最初の一文字が絵柄.

		char temp[3];
		strncpy(temp,Array[i] + 1, 2);
		card1[i].number = atoi(temp);

		card1[i].originIndex = i;

		card2[i] = card1[i];
	}

	BubbleSort(card1, inputNum, Array);

	// 絶対安定.
	printf("Stable\n");

	SelectionSort(card2, inputNum, Array);

	bool isDiff = false;
	for (int i = 0; i < inputNum; i++) {
		if (card1[i].originIndex != card2[i].originIndex) {
			isDiff = true;
		}
	}

	if (isDiff) {
		printf("Not stable\n");
	}
	else {
		printf("Stable\n");
	}


	return 0;
}

void BubbleSort(SCard* cardArray, int arraySize, const char originalInput[][INPUT_LENGTH_MAX])
{

	bool isSort = true;
	int sortedIndex = 0;
	while (isSort) {
		isSort = false;
		for (int i = arraySize - 1; i > sortedIndex; i--) {
			if (cardArray[i - 1].number > cardArray[i].number) {
				swap(cardArray[i - 1], cardArray[i]);
				isSort = true;
			}
		}

		sortedIndex++;
	}

	// 結果出力
	// ソート済み配列
	for (int i = 0; i < arraySize; i++) {
		if (i != arraySize - 1) {
			printf("%s ", originalInput[cardArray[i].originIndex]);
		}
		else {
			printf("%s\n", originalInput[cardArray[i].originIndex]);
		}
	}
}

void SelectionSort(SCard* cardArray, int arraySize, const char originalInput[][INPUT_LENGTH_MAX])
{

	for (int i = 0; i < arraySize; i++) {
		int minIndex = i;

		for (int j = i + 1; j < arraySize; j++) {
			if (cardArray[minIndex].number > cardArray[j].number) {
				minIndex = j;
			}
		}

		if (minIndex != i) {
			swap(cardArray[minIndex], cardArray[i]);
		}
	}

	// 結果出力
	// ソート済み配列
	for (int i = 0; i < arraySize; i++) {
		if (i != arraySize - 1) {
			printf("%s ", originalInput[cardArray[i].originIndex]);
		}
		else {
			printf("%s\n", originalInput[cardArray[i].originIndex]);
		}
	}
}


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

int main()
{
	long long int a[3000],ans=0,N;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> a[i];
		ans += a[i] - 1;
	}

	cout << ans << endl;

	return 0;
}

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

const int maxN = 6005;

int n, mod;
int fac[maxN + 1], inv[maxN + 1];
int f[maxN + 1][maxN * 2 + 1];

inline int ADD(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }

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

int main()
{
	scanf("%d %d", &n, &mod);

	fac[0] = 1;
	for(int i = 1; i <= 3 * n; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[3 * n] = mpow(fac[3 * n], mod - 2);
	for(int i = 3 * n - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;

	for(int i = 1; i <= 3 * n; i++) inv[i] = 1ll * inv[i] * fac[i - 1] % mod;

	int lim = 3 * n;
	f[0][lim] = 1;
	for(int i = 1; i <= 3 * n; i++)
		for(int j = lim - i; j <= lim + i; j++)
		{
			f[i][j] = ADD(f[i][j], 1ll * f[i - 1][j - 1] * inv[i] % mod);
			if(i >= 2) f[i][j] = ADD(f[i][j], 1ll * f[i - 2][j + 1] * inv[i] % mod);
			if(i >= 3) f[i][j] = ADD(f[i][j], 1ll * f[i - 3][j] * inv[i] % mod);
		}

	int ans = 0;
	for(int j = lim; j <= lim + 3 * n; j++) ans = ADD(ans, f[3 * n][j]);
	ans = 1ll * ans * fac[3 * n] % mod;

	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 279936
#include <bits/stdc++.h>
using namespace std;
class finite_field {
  const int md;
  const int sz;
  vector<int> fct, fnv;
  int inv2;
  public :
    finite_field(
        const int md,
        const int init_factorial_size = 0,
        const int init_power_size = 0
      ) :
      md(md), sz(init_factorial_size),
      fct(sz), fnv(sz)
      {
        if (sz) {
          fct[0] = 1;
          for (int i = 1; i < sz; i++) fct[i] = prod(fct[i - 1], i);
          fnv[sz - 1] = inv(fct[sz - 1]);
          for (int i = sz - 1; i >= 1; i--) fnv[i - 1] = prod(fnv[i], i);
        }
        inv2 = inv(2);
      }
    inline void add (int& a, const int b) const {
      a += b;
      if (a >= md) a -= md;
    }
    inline void sub (int& a, const int b) const {
      a -= b;
      if (a < 0) a += md;
    }
    template<class... A> inline int sum (A... args) const {
      int ret = 0;
      for (int a : initializer_list<int>{args...}) {
        add(ret, a);
      }
      return ret;
    }
    inline int dif (int a, int b) const {
      sub(a, b);
      return a;
    }
    template<class... A> inline int prod (A... args) const {
      long long ret = 1;
      for (int a : initializer_list<int>{args...}) {
        ret *= a;
        ret %= md;
      }
      return (int)ret;
    }
    void mul (int& a, int b) const {
      a = prod(a, b);
    }
    inline int inv (int a) const {
      if (a == 2) return inv2;
      a %= md; if (a < 0) a += md;
      int b = md, u = 0, v = 1;
      while (a) {
        int t = b / a;
        b -= a * t; swap(a, b);
        u -= v * t; swap(u, v);
      }
      assert(b == 1);
      if(u < 0) u += md;
      return u;
    }
    inline int quat (int a, int b) const {
      return prod(a, inv(b));
    }
    void div (int& a, int b) const {
      a = quat(a, b);
    }
    inline int pow (int a, long long b) {
      int ret = 1;
      for (; b; b >>= 1) {
        if (b & 1) mul(ret, a);
        a = prod(a, a);
      }
      return ret;
    }
    inline int binom (int n, int k) const {
      assert(0 <= n && n < sz);
      if (k < 0 || n < k) return 0;
      return prod(fct[n], fnv[k], fnv[n - k]);
    }
};
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  finite_field fld(1e9 + 7);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int mx = *max_element(a.begin(), a.end());
  vector<int> sum_dp(mx + 1, 0);
  vector<int> dp(n + 1);
  dp[0] = 1; sum_dp[a[0]] += 1;
  for (int i = 1; i <= n; i++) {
    if (i < n && a[i] == a[i - 1]) continue;
    dp[i] = sum_dp[a[i - 1]];
    if (i < n) fld.add(sum_dp[a[i]] , dp[i]);
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 2688
r, g, b, n = gets.chomp.split.map(&:to_i)

count = 0
0.upto(3_000).each do |i|
  rc = r * i
  break if rc > n
  0.upto(3_000).each do |j|
    gc = g * j
    res = n - rc - gc
    break if res < 0
    count += 1 if res % b == 0
  end
end
puts count


Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int i,flag=0;
    for(i=0;i<3;i++)
    {
        if(n%10==7)
        {
            flag=1;
            break;
            
        }
        n=n/10;
    }
    if(flag==0)
    cout<<"No"<<"\n";
    else
    cout<<"Yes"<<"\n";
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

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

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

  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

vector<vector<ll>> a(200005);
ll ans[200005];

void dfs(ll l, ll num, ll parent)
{
	ans[l] += num;
	rep(i, a[l].size()) {
		if (a[l][i] == parent)
			continue;
		else
			dfs(a[l][i], ans[l], l);
	}

	return;
}


int main()
{
	cout << fixed << setprecision(18);

	ll n, q;
	cin >> n >> q;

	ll pa, b, p, x;
	memset(ans, 0, sizeof(ans));

	rep(i, n - 1) {
		cin >> pa >> b;
		a[pa].push_back(b);
		a[b].push_back(pa);
	}
	rep(i, q) {
		cin >> p >> x;
		ans[p] += x;
	}

	dfs(1, ans[0], 0);

	rep1(i, n + 1) {
		cout << ans[i];
		if (i != n)
			cout << " ";
	}
	cout << endl;

	return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod=1000000007;
//head

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

    ll n, weight;
    cin >> n >> weight;

    vll w(n+1); vll v(n+1);
    rep(i,1,n+1) cin >> w[i] >> v[i];
    int maxi = 0;
    for(int i = 1; i < n + 1; i++) maxi += v[i];
    vector<vll> dp(maxi+1,vll(n+1,1LL << 60));
    for(int i = 0; i < n + 1; i++) dp[0][i] = 0;
    ll ans = 0;
    for(int i = 1; i <= maxi; i++) {
        for(int j = 1; j <= n; j++) {
            dp[i][j] = dp[i][j-1];
            if(i - v[j] >= 0) {
                dp[i][j] = min(dp[i-v[j]][j-1] + w[j], dp[i][j]);
            }
            if(dp[i][j] <= weight)
                ans = max((ll)i, ans);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 82304
#include<iostream>
using namespace std;
int main(){
  while(1){
    int x,y;
    cin >> x >> y;
    if (x == 0 && y == 0 ) break;
    if ( x >= y) {
      cout << y << " " << x << endl;}
    else {
      cout << x << " " << y << endl;}
  }
  return 0;
}


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

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


int main()
{
	int h, w; cin >> h >> w;
	vector<string> s(h);
	rep(i, h)cin >> s[i];
	vector<vector<int>> dp(h, vector<int>(w, 10000));
	dp[0][0] = 0;
	rep(i, h)rep(j, w)
	{
		if (i - 1 >= 0)
		{
			if (s[i - 1][j] == '.'&&s[i][j] == '#')dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
			else dp[i][j] = min(dp[i][j], dp[i - 1][j]);
		}
		if (j - 1 >= 0)
		{
			if (s[i][j - 1] == '.'&&s[i][j] == '#')dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
			else dp[i][j] = min(dp[i][j], dp[i][j - 1]);
		}
	}
	int res = dp[h - 1][w - 1];
	if (s[0][0] == '#')++res;
	cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

#include<string>
#include<stdlib.h>
#include<memory>

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7


map<ll,ll> prime_factorization(ll n)
{
	map<ll,ll> res;
	ll check = 2;

	while(check*check <= n) {
		if(n%check == 0) {
			n /= check;
			res[check]++;
		}
		else {
			check++;
		}
	}
	if(n != 1) res[n]++;
	return res;
}

//変数
ll N,P;



//サブ関数
//入力
void input()
{
	cin >> N>>P;
}


//計算
void calc()
{
	auto primes = prime_factorization(P);

	ll res = 1;
	for(auto itr = primes.begin(); itr != primes.end(); ++itr) {
		ll times = (itr->second)/N;
		for(int i=0;i<times;i++)res *=itr->first;
	}
	cout << res<<endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
    int N;
    cin>>N;
}


//メイン関数
int main()
{
    input();
    calc();
    output();
    debug();
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
const ll MOD=1000003;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}
inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return v[(size / 2) - 1] ;
}
template<class T> inline bool chmax(T& a,T b) {if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b) {if(a>b){a=b;return 1;} return 0;}
template<class T,class L>ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}

int main(){
    string s;
    cin>>s;
    bool a=0,b=0,c=0,d=0;
    rep(i,0,s.size()){
        if(s[i]=='N') a=1;
        if(s[i]=='S') b=1;
        if(s[i]=='E') c=1;
        if(s[i]=='W') d=1;
    }
    if((a^b)|(c^d)) cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1e9
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int N, K;
    cin >> N >> K;

    vector<ll> H(N);
    REP(i,N) cin >> H[i];
    sort(H.begin(), H.end(), greater<int>());

    ll cnt=0;
    if(N>K){
        FOR(i,K,N){
            cnt+=H[i];
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


void solve(){
	int n,k;
	cin >> n >> k;
	ll a[n];
	forn(i,0,n) cin >> a[i];
	string yes = "Yes", no = "No";
	for(int i =k;i<n;i++){
		if(a[i]>a[i-k])
			cout << yes << endl;
		else cout << no << endl;
	}
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 5220
#include <stdio.h>
#include <stdlib.h>

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

Measured memory_bytes: 596
z[75][75];s,d,t,a,*p,j;main(i){for(;scanf("%d%d",&s,&d)*s;printf("%d\n",s)){for(memset(z,j=++d,2e4);s--;)for(i=d;--i;a&&*p>a?*p=a,*z[t]>a?t=i:0:0)scanf("%d",&a),p=z[i];for(;--j;)for(s=j;--s;a?z[s][j]=z[j][s]=a:0)scanf("%d",&a);for(s=i=0;d+~i++;t=a)for(s+=*z[t],*z[t]=0,a=j=d;--j;*p&&*z[a]>*p?a=j:0)p=z[j],*p=fmin(*p,p[t]);}}

Measured memory_bytes: 0
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	string s;
	while(cin>>N) {
		PII m=MP(0,0);
		RANGE(i, 1, N+1) {
			ll c=0;
			ll v=i;
			while(v%2==0) v/=2,c++;
			maxUpdate(m, MP(c, i));
		}
		cout<<m.SE<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll a,b;
	char c;
	while(true){
		cin >> a >> c >> b;
		if(c=='?')
			break;
		else if(c=='+')
			cout << a+b << endl;
		else if(c=='-')
			cout << a-b << endl;
		else if(c=='*')
			cout << a*b << endl;
		else
			cout << a/b << endl;
	}
}


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

using namespace std;

int main()
{
    int N, res = 0;
    string target, s;
    cin >> target >> N;
    for (int i = 0; i < N; i++) {
        cin >> s;
        for (int j = 0; j < (int)s.size(); j++) {
            rotate(s.begin(), s.begin() + 1, s.end());
            if (s.substr(0, target.size()) == target) {
                res++;
                break;
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3196
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int N = sc.nextInt();
        int[] arr = new int[N];
        int a;
        a = arr[0] = sc.nextInt();
        for(int i = 1; i < N; i++) {
            arr[i] = sc.nextInt();
            a ^= arr[i];
        }
        for(int i = 0; i < N; i++) {
            System.out.print(a ^ arr[i]);
            System.out.print(" ");
        }
    }
}

Measured memory_bytes: 59964
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, A[100005];

int main() {
  INCANT;
  cin >> N;
  rep(i, N) cin >> A[i];
  sort(A, A+N);
  int left = 0;
  int right = 0;
  int ans = 0;
  while(right<N) {
    if (A[right]<=A[left]+2) right++;
    else {
      ans = max(ans, right-left);
      left++;
    }
  }
  ans = max(ans, right-left);
  cout << ans << "\n";
  return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  int i, A;
  int64_t sum;
  priority_queue<int> a;
  for(i=0; i<N; i++){
    cin >> A;
    a.push(A);
  }
   for(i=0; i<M; i++){
     A = a.top();
     a.pop();
     a.push(A/2);
   }
  sum=0;
  for(i=0; i<N; i++){
    sum += a.top();
    a.pop();
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 892