akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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



Measured memory_bytes: 26272
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

input = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b = list(map(int,input().split()))

    if a < 10 and b < 10:
        print(a*b)
    else:
        print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38512
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  char pre=' ',now;
  int cnt = 0;
  for(int i=0;i<n;i++){
    cin >> now;
    if(pre!=now){
      cnt++;
    }
    pre = now;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long q,x,y,i,j,k,l,a,b,c,ans,bz[15][2][2];
long long ss(long long u,long long v,long long w,long long flag){
	if(w==i){
		ans=(ans+(y-v)/u+1)%mo;
		swap(u,v);
		if(u>x)
			return 0;
		if(u==v)
			ans=(ans+(x-u)/v)%mo;
		else
			ans=(ans+(x-u)/v+1)%mo;
		return 0;
	}
	if(flag==1){
		a=u;b=v;
		for(j=0;(1<<j)<=i-w;j++)
			if((1<<j)&(i-w)){
				c=b*bz[j][0][0]+a*bz[j][0][1];
				a=b*bz[j][1][0]+a*bz[j][1][1];
				b=c;
			}
		if(a>x||b>y)
			return 0;
		ss(a,b,i,0);
		return 0;
	}
	ss(v,v+u,w+1,0);
	ss(u,v+u,w,1);
}
int main(){
    bz[0][0][0]=1;bz[0][0][1]=1;
    bz[0][1][0]=1;bz[0][1][1]=0;
    for(i=1;i<=6;i++)
    	for(j=0;j<=1;j++)
    		for(k=0;k<=1;k++)
    			for(l=0;l<=1;l++)
    				bz[i][j][k]+=bz[i-1][j][l]*bz[i-1][l][k];
   	q=read();
   	while(q--){
		x=read();y=read();
		if(x>y)
			swap(x,y);
		a=1;b=1;
		for(i=0;b<=x&&a+b<=y;i++){
			c=b;
			b=a+b;
			a=c;
		}
		if(i<=1){
			pus(1,1);
			pus((x%mo)*(y%mo)%mo,2);
		}
		else{
			pus(i,1);
			ans=0;
			ss(1,2,1,0);
			pus(ans,2);
		}
	}
    return 0;
}

Measured memory_bytes: 3968
import java.util.Scanner;


public class Main {

	public static void main(String[] args) throws Exception{
		// TODO ?????????????????????????????????????????????
		int a, b;
		int ans = 0;
		//String str[];
		String op = "";

		/*while(!op.equals("?")){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        str = br.readLine().split(" ");*/
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
	        a = scan.nextInt();
	        op = scan.next();
	        b = scan.nextInt();

	        switch(op){
		        case "+":
		        	ans = a + b;
		        	break;
		        case "-":
		        	ans = a - b;
		        	break;
		        case "*":
		        	ans = a * b;
		        	break;
		        case "/":
		        	ans = a / b;
		        	break;
	        }
	        if (!op.equals("?")) System.out.println(ans);
	        else break;

		}

	}

}

Measured memory_bytes: 26320
N, Y = gets.split.map(&:to_i)

# 10000円札の枚数でループする
# (0..Y / 10000)これだとNの枚数が極端に少ない場合に無駄にループしてしまう
# 無駄なループをしないために[N, Y / 10000].minにする
(0..[N, Y / 10000].min).each do |a|
  n = N - a # n = b + c
  m = Y - 10000 * a # m = 5000b + 1000c
  # cの値はc = N - a - bで求められるのでcが消えるように式を解く
  # m / 1000 - n = 4b
  # このときbはマイナスにはならない
  next if (s = m / 1000 - n) < 0
  # s = 4bなので、sは4で割り切れる(割り切れない場合、cが少数を含む値になる)
  b, r = s.divmod(4)
  if r == 0 && (c = N - a - b) >= 0
    puts [a, b, c] * " "
    exit
  end
end

puts '-1 -1 -1'



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

using namespace std;

int main() {
  char c[10];
  cin >> c;
  sort(c, c + 4);
  if (c[0] == c[1] && c[2] == c[3] && c[1] != c[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
s = input()
t = input()
start = max(0, len(s)-len(t))
def solve():
    for i in range(start,len(s)):
        for j in range(len(t)):
            if i+j >= len(s):
                return 2*N-(len(s)-i)
            if s[i+j] != t[j]:
                break
        else:
            return 2*N-(len(s)-i)
    return 2*N
print(solve())

Measured memory_bytes: 38256
n = int(input())
v = list(map(int ,input().split()))
c = list(map(int ,input().split()))
cnt = []
for i in range(n):
        cnt.append(v[i]-c[i])
ans = 0
for i in range(n):
        if cnt[i]>=0:
                ans += cnt[i]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    double a;
    cin>>a;
    cout<<2*a*3.1415<<endl;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<double> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  
  vector<double> ap(N);
  vector<double> sum(N - K + 1);
  float Ans;
  for (int i = 0; i < N; i++) {
    ap.at(i) = (p.at(i) + 1) / 2;
  }
  for (int i = 0; i < K; i++) {
    sum.at(0) += ap.at(i);
  }
  for (int i = 1; i < N - K + 1; i++) {
    sum.at(i) = sum.at(i-1) - ap.at(i-1) + ap.at(i+K-1);
  }
  sort(sum.begin(), sum.end(), greater<float>());
  Ans = sum.at(0);
  printf("%f\n", Ans);
}


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

using namespace std;

int main() {

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int res = 0;
    res += min(a, k);
    k -= min(a, k);
    k -= min(b, k);
    res -= min(c, k);
    cout << res;


    return 0;
}

Measured memory_bytes: 3652
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
prev = 0

for i in range(len(a)):
  ans += b[a[i] - 1]

  if (i != 0 and prev == a[i] - 1):
    ans += c[prev - 1]
  prev = a[i]

print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
//g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG b.cpp
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define scint(x) scanf("%d", &x)
#define scll(x) scanf("%lld", &x)

typedef long long ll;

int a, b, c, d;

int dfs(int e, int f, int g, int cnt){
    int ans = a;
    char s, t, u;
    if(e == 0){
        ans += b;
        s = '+';
    }else{
        ans -= b;
        s = '-';
    }
    if(f == 0){
        ans += c;
        t = '+';
    }else{
        ans -= c;
        t = '-';
    }
    if(g == 0){
        ans += d;
        u = '+';
    }else{
        ans -= d;
        u = '-';
    }

    if(ans == 7){
        cout << a << s << b << t << c << u << d << "=7" << "\n";
        return 1;
    }else{
        if(cnt == 0){
            int h = dfs(1, f, g, 1);
            if(h == 1){
                return h;
            }
            h = dfs(0, f, g, 1);
            return h;
        }else if(cnt == 1){
            int h = dfs(e, 1, g, 2);
            if(h == 1){
                return h;
            }
            h = dfs(e, 0, g, 2);
            return h;
        }else if(cnt == 2){
            int h = dfs(e, f, 1, 3);
            if(h == 1){
                return h;
            }
            h = dfs(e, f, 0, 3);
            return h;
        }
    }
    return 0;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int k;
    cin >> k;
    a = k/1000;
    k -= a * 1000;
    b = k/100;
    k -= b * 100;
    c = k/10;
    k -= c * 10;
    d = k;

    int topei = dfs(0, 0, 0, 0);
    if(topei == 0){
        cout << topei << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,x,sum;
  long long min,max;
  min = 1000000;
  max = 1000000;
  max *= -1;
  sum = 0;
 cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x; 
      sum += x;
      if(min > x)min = x;
      if(max < x)max = x;
    }
  cout << min << " " << max << " " << sum << endl;
}


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

using namespace std;
int v[55];
int r[51][55],l[51][55];
int ri[51],li[51];

int n,k;
int main()
{
   //freopen("C://Code//input.txt","r",stdin);
   scanf("%d%d",&n,&k);
   for(int i=0;i<n;++i) scanf("%d",v+i);

   for(int i=0;i<n;++i){
        ri[i+1] = ri[i]+v[i];
        li[i+1] = li[i]+v[n-1-i];
   }

   for(int i=1;i<=n;++i)
   {
       memcpy(r[i],v,sizeof(int)*i);
       sort(r[i],r[i]+i);
       memcpy(l[i],v+n-i,sizeof(int)*i);
       sort(l[i],l[i]+i);
   }

   k = min(k,n*2);
   int ans = 0;

   for(int i=0;i<=k/2;++i)
   {
       int g = min(n,k-i),nc = 0;
       for(int j=0;j<=g;++j){
            int mx = ri[g-j]+li[j];
            int rn = 0,ln = 0;
            while((ln+rn+g<k)&&((rn<g-j&&r[g-j][rn]<0)||(ln<j&&l[j][ln]<0))){
                if(ln<j&&rn<g-j){
                    if(r[g-j][rn]<l[j][ln]) mx-=r[g-j][rn++];
                    else mx -= l[j][ln++];
                }
                else{
                    if(rn<g-j) mx-=r[g-j][rn++];
                    else mx -= l[j][ln++];
                }
            }
            ans = max(ans,mx);
       }
   }
   printf("%d\n",ans);
   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define INF 9999999

int m[N][N], p[N], n;

void matrixChainOrder(){

  int i, j, k, l, q;

  for(i = 1 ; i <= n ; i++){
    m[i][i] = 0;
  }
  for(l = 2 ; l <= n ; l++){
    for(i = 1 ; i <= n - l + 1 ; i++){
      j = i + l -1;
      m[i][j] = INF;
      for(k = i ; k <= j-1 ; k++){
	q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
	if(q < m[i][j]){
	  m[i][j] = q;
	}
      }
    }
  }
  
}

int main(){

  int  a, i;

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

  matrixChainOrder();
  
  printf("%d\n", m[1][n]);  

  return 0;
}

Measured memory_bytes: 2752
#include<stdio.h>
#define N 101

int main(){
  int i,j,k,n;
  int A[N];
  int key;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
   
  for(i=0;i<n;i++){
    key=A[i];
    j=i-1;
    while(j>=0&&A[j]>key){
      A[j+1]=A[j];
      j--;
      A[j+1]=key;
    }
    for(k=0;k<n;k++){
      if(k!=0) printf(" ");
      printf("%d",A[k]);
    }
    printf("\n");
  }
  
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	vll a(5);
	cin>>n;
	rep(i, 5) cin>>a[i];
	sort(all(a));
	cout << (n-1)/a[0]+5 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define  fo(i,n) for(ll i=0;i<n;i++)
#define rfo(i,n) for(ll i=n;i>=0;i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define pb push_back
#define deb(x) cout<< #x << " = "<<x<<endl;
#define F first
#define S second
#define MP make_pair
#define all(x) (x).begin(), (x).end()

void solve()
{
	ll n;
	cin>>n;
	ll ans =0;
	vector<ll> a(n);
	fo(i,n)
	{
		cin>>a[i];
	}
	for(ll i=1;i<n;i++)
	{
		if(a[i]<a[i-1])
		{
			ans = ans + (a[i-1]-a[i]);
			a[i] = a[i-1];
			}	
	}
	cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 4772
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Data.List   (transpose)
import qualified Data.Vector as V

main :: IO ()
main = do
  s <- getLine
  print $ solve s

solve :: String -> Int
solve s = abc where
  [n, a, ab, abc] = V.foldl' f [1, 0, 0, 0] $ V.fromList s
  f [n, a, ab, abc] 'A' = [n, add a n, ab, abc]
  f [n, a, ab, abc] 'B' = [n, a, add ab a, abc]
  f [n, a, ab, abc] 'C' = [n, a, ab, add abc ab]
  f [n, a, ab, abc] '?' = map (foldr add 0) . transpose $ map (f [n, a, ab, abc]) "ABC"

add :: Int -> Int -> Int
add x y = (x + y) `mod` modN

modN :: Int
modN = 10 ^ 9 + 7


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

using namespace std;

int N, M, P[100001];
string S[100001];

int ac_sum = 0, wc_sum = 0;
bool ac[100001];
int wc[100001];

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        ac[i] = false;
        wc[i] = 0;
    }
    for (int i = 0; i < M; i++) {
        cin >> P[i] >> S[i];
        P[i]--;
        if (ac[P[i]]) {
            continue;
        }
        if (S[i] == "AC") {
            ac_sum++;
            ac[P[i]] = true;
        }
        else {
            wc[P[i]]++;
        }
    }
    for (int i = 0; i < N; i++) {
        if (ac[i]) {
            wc_sum += wc[i];
        }
    }
    cout << ac_sum << ' ' << wc_sum << endl;
    return 0;
}


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

using namespace std;

const int N = 123456;

int n, k, answer, a[N], d[N];
vector<int> adj[N];

void dfs(int x) {
  for (auto y : adj[x]) {
    dfs(y);
    d[x] = max(d[x], d[y] + 1);
  }
  if (x > 1 && d[x] == k - 1 && a[x] != 1) {
    ++answer;
    d[x] = -1;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k >> a[1];
  if (a[1] != 1) {
    ++answer;
  }
  for (int i = 2; i <= n; ++i) {
    cin >> a[i];
    adj[a[i]].push_back(i);
  }
  dfs(1);
  cout << answer << '\n';
  return 0;
}

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

int main(){
	int n, k;
	vector<int> dp;
	while(true){
		cin >> n;
		if(n == 0)
			return 0;
		for(int i = 0; i < n; i++){
			cin >> k;
			if(i == 0)
				dp.push_back(k);
			else
				dp.push_back(max(dp[i -1] + k, k));
		}
		int max = dp[0];
		for(int i = 0; i < n; i++){
			if(max < dp[i]){
				max = dp[i];
			}
		}
		dp.clear();
		cout << max << endl;
	}
}

Measured memory_bytes: 3020
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int32_t main(){_

   int x, a;
   cin>>x>>a;
   if (x<a){
      cout<<0;
   }
   else{
      cout<<10;
   }
   

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works

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

int h, w;
string a[101];
int cnt[26];


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

  cin >> h >> w;
  for(int i = 0; i < h; ++i) {
    cin >> a[i];
    for(int j = 0; j < w; ++j) {
      ++cnt[a[i][j] - 'a'];
    }
  }

  // 求める条件は、縦対称、横対称、つまり斜め対称
  // pattern : (h, w) = (odd, odd), (odd, even), (even, even)
  if(h % 2 == 0 && w % 2 == 0) {
    for(int i = 0; i < 26; ++i) {
      if(cnt[i] % 4) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  } else if (h % 2 && w % 2) {
    int rem = 0, center_cnt = 0, max = h/2 + w/2;
    for(int i = 0; i < 26; ++i) {
      if(cnt[i] % 4) {
        if(cnt[i] % 2) {
          if(center_cnt) {
            cout << "No" << endl;
            return 0;
          }
          ++center_cnt;
        } else {
          ++rem;
          if(rem > max) {
            cout << "No" << endl;
            return 0;
          }
        }
      }
    }
    cout << "Yes" << endl;
  } else {
    int rem = 0;
    for(int i = 0; i < 26; ++i) {
      if(cnt[i] % 4) {
        if(cnt[i] % 2) {
          cout << "No" << endl;
          return 0;
        } else {
          ++rem;
          if((w%2==0&&rem>w/2) || (h%2==0&&rem>h/2)) {
            cout << "No" << endl;
            return 0;
          }
        }
      }
    }
    cout << "Yes" << endl;
  }
  return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  int c[n];
  vector<vector<int>> a(n, vector<int>(m));
  rep(i, n) {
    cin >> c[i];
    rep(j, m) cin >> a[i][j];
  }

  int ans = 1001001001;
  rep(s, 1 << n) {
    int now = 0;
    vector<int> d(m);
    rep(i, n) {
      if (s >> i & 1) {
        rep(j, m) d[j] += a[i][j];
        now += c[i];
      }
    }

    bool ok = true;
    rep(i, m) if (d[i] < x) ok = false;
    if (ok) ans = min(ans, now);
  }

  if (ans == 1001001001) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pi 3.14159265358979
int main() {
	int n;
	cin >> n;
	int i = 1;
CHECK_NUM:
	int x = i;
	if (x % 3 == 0) {
		cout << " " << i;
		goto END_CHECK_NUM;
	}
INCLUDE3:
	if (x % 10 == 3) {
		cout << " " << i;
		goto END_CHECK_NUM;
	}
	x /= 10;
	if (x) goto INCLUDE3;
END_CHECK_NUM:
	if (++i <= n) goto CHECK_NUM;

	cout << endl;
	return 0;
}


Measured memory_bytes: 3128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            Dictionary<char, int> roman = new Dictionary<char, int>()
            {
                {'I',1 }, {'V',5 }, {'X',10 }, {'L',50 },
                {'C',100 }, {'D',500 }, {'M',1000 }
            };

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                int index = input.Length - 1;
                int sum = roman[input[index]];

                for (int i = index; i > 0; i--)
                {
                    if (roman[input[i]] > roman[input[i - 1]]) sum -= roman[input[i - 1]];
                    else sum += roman[input[i - 1]];
                }
                sb.AppendLine(sum.ToString());
            }
            Console.Write(sb);
        }
    }
}

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

using namespace std;

typedef long long ll;

int main() {
    int N;
    float ans;

    cin >> N;

    float mid;
    mid = (N + 1) / 2;

    if (N % 2 == 0) {
        ans = 0.5;
    } else if (N % 2 == 1) {
        ans = mid / N;
    }

    if (N == 1) {
        ans = 1;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
X, Y = map(int, input().split())
ans = 0
for v in [X, Y]:
    if v == 1:
        ans += 300000
    elif v == 2:
        ans += 200000
    elif v == 3:
        ans += 100000

if X == 1 and Y == 1:
    ans += 400000

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();
    
    int x;
    cin >> x;

    vector<string> ans = { "thu","fri","sat","sun","mon","tue","wed" };
    cout << ans[x % 7] << "\n";
}


Measured memory_bytes: 3256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  int N; cin >> N;
  vector <ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());

  ll ans1 = 0;
  ll now1 = A[0], now2 = A[0];
  int index_L = 1, index_R = N - 1;
  while (index_L <= index_R){
    vector <Pli> now(4);
    now[0] = make_pair(abs(now1 - A[index_L]), 0);
    now[1] = make_pair(abs(now1 - A[index_R]), 1);
    now[2] = make_pair(abs(now2 - A[index_L]), 2);
    now[3] = make_pair(abs(now2 - A[index_R]), 3);
    sort(now.begin(), now.end(), greater<Pli>());

    ans1 += now[0].first;
    int num = now[0].second;
    if (num == 0){
      now1 = A[index_L]; index_L++;
    }else if (num == 1){
      now1 = A[index_R]; index_R--;
    }else if(num == 2){
      now2 = A[index_L]; index_L++;
    }else{
      now2 = A[index_R]; index_R--;
    }
  }

  cout << ans1 << endl;

  return 0;
}


Measured memory_bytes: 1024
n,k=map(int,input().split())
p=list(map(int,input().split()))
for i in range(n):
  p[i]=(p[i]+1)/2
x=[0]
for i in range(n):
  x.append(p[i]+x[-1])
l=[]
for i in range(n-k+1):
  l.append(x[i+k]-x[i])
print(max(l))

Measured memory_bytes: 83592
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
const int N=1e5+7;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	string s;
	cin>>s;
	if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]) {
		cout<<"Bad"<<endl;
	}
	else{
		cout<<"Good"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ab = a * b;
	ll cd = c * d;

	if (ab >= cd) {
		cout << ab << "\n";
	} else {
		cout << cd << "\n";
	}

}


Measured memory_bytes: 256
N,M=map(int,input().split())
L=[]
ans=0

for i in range(N):
    a,b=map(int,input().split())

    L.append([a,b])

L= sorted(L)

for i in range(N):

    if M < L[i][1]:
        ans=L[i][0]*M

        print(ans)
        exit()
        
    else:
        ans += L[i][0]*L[i][1]
        M -= L[i][1]

        if M==0:

            print(ans)
            exit()

        elif M <= L[i+1][1]:

            ans += M * L[i+1][0]
            print(ans)
            exit()

        




Measured memory_bytes: 20816
#include<stdio.h>
int main()
{
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c)!=EOF)
	{
		if((c <= a && c >= b) || (c <= b && c >= a)) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/abc144/tasks/abc144_b
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: i32
    };
    for i in 1..10 {
        for j in 1..10 {
            if i * j == n {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


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

using namespace std;

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

    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    
    int ans=0;
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(int i=0;i<n/2;i++){
        ans+=a[2*i]-a[2*i+1];
    }
    if(a.size()%2) ans+=a[a.size()-1];
    
    cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        int m=fsc.nextInt();
        boolean[] isac=new boolean[n];
        int ac=0;
        int wa=0;
        int[] was=new int[n];
        for(int i=0;i<m;i++){
            int p=fsc.nextInt()-1;
            char[] s=fsc.next().toCharArray();
            if(!isac[p]){
                if(s[0]=='W'){
                    was[p]++;
                } else{
                    ac++;
                    isac[p]=true;
                }
            }
        }
        for(int i=0;i<n;i++){
            if(isac[i]){
                wa+=was[i];
            }
        }
        fsc.close();
        System.out.println(ac+" "+wa);
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 39328
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N)cin >> A[i];
    if(A[0]!=0){
        cout << -1 << endl;
        return 0;
    }
    ll ans = 0;
    for(int i=1;i<N;i++){
        if(A[i]==A[i-1])ans += A[i];
        else if(A[i]==A[i-1]+1){
            ans++;
        }else if(A[i]>A[i-1]+1){
            cout << -1 << endl;
            return 0;
        }else{
            ans += A[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mod 1000000007
#define fir first
#define sec second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

inline int add(int x,int y){
	x += y;if (x >= mod) x -= mod;
	return x;
}

inline int sub(int x,int y){
	x -= y;if (x < 0) x += mod;
	return x;
}
inline int qpow(int x,int y){
	int res = 1;
	while (y){
		if (y & 1) res = 1ll * res * x % mod;
		x = 1ll * x * x % mod;
		y >>= 1;
	}
	return res;
}
const int N = 1e5 + 10;

int n , h[N];
pii solve(int l,int r,int lim){//first not ababab second ababa
	int minm = 0x3f3f3f3f , cntminm = 0 , block = 0;
	for (int i = l;i <= r;i++){
		if (h[i] < minm){
			minm = h[i];
			cntminm = 0;
		}
		if (h[i] == minm) cntminm++;
	}
	
	if (cntminm == r - l + 1){
//		printf("%d %d %d [%d %d]\n",l,r,lim,qpow(2,r-l+1)-2,qpow(2,h[l]-lim));
		return mp(qpow(2 , r - l + 1) - 2 , qpow(2 , h[l] - lim));
	}
	
	pii res = mp(1 , 1);
	for (int i = l;i <= r;i++){
		if (h[i] == minm) continue;
		int j = i;while (j + 1 <= r && h[j + 1] != minm)j++;
		
		pii tmp = solve(i , j , minm);
		res.first = 1ll * res.first * add(tmp.first , 2ll * tmp.second % mod) % mod;
		res.second = 1ll * res.second * tmp.second % mod;
		block++;
		i = j;
	}
	
	res.first = 1ll * qpow(2 , cntminm) * res.first % mod;
	res.first = sub(res.first , 2ll * res.second % mod);
	res.second = 1ll * qpow(2 , minm - lim) * res.second % mod;
	
//	printf("%d %d %d %d %d\n",l,r,lim,res.fir,res.sec);
	return res;
}

int main() {
	cin >> n;
	for (int i = 1;i <= n;i++) cin >> h[i];
	pii res = solve(1 , n , 0);
	
	cout<<add(res.first,res.second);


	return 0;
}

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

#define fast                     ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int                      long long 
#define mk                       make_pair
#define pb                       push_back
#define pob                      pop_back
#define pii                      pair<int,int>
#define vi                       vector<int>
#define vii                      vector<pii>
#define mi                       map<int,int>
#define mii                      map<pii,int>
#define all(a)                   (a).begin(),(a).end()
#define x                        first
#define y                        second
#define sz(x)                    (int)x.size()
#define endl                     '\n'
#define MOD                      1000000007
#define loop(i,a,b)              for(int (i)=(a);(i)<(b);(i)++)
#define rloop(i,a,b)             for(int (i)=(a);(i)>=(b);(i)--)
#define Unique(A)                (A).resize(distance((A).begin(),unique(all((A)))));
#define mxe(A)                   *max_element(all(A))
#define mne(A)                   *min_element(all(A))
#define debv(x)                  for(auto i : (x)) cout << i << ' ';cout << endl;
#define SP(x,y)                  cout << fixed << setprecision((y)) << (x) << endl;
#define setBits(x)               __builtin_popcountll(x)
#define zroBits(x)               __builtin_ctzll(x)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define Max(x,y,z)               max(x,max(y,z))
#define Min(x,y,z)               min(x,min(y,z))
#define clr(x)                   memset(x,0,sizeof(x)) // not sure work for 2D arrya or not

using namespace std;

int v[1100] , w[1100], dp[110][110000];

int32_t main(){
    int n , W ; cin >> n >> W ;
    loop(i,1,n+1) cin >> w[i] >> v[i];

    loop(i,1,n+1){
        loop(j,1,W+1){
            if(j<w[i]) dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            else dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
        }
    }
    cout << dp[n][W] << endl;
    // int ans = 0;
    // cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 87424
import Data.Set (Set, toList, fromList, findMax, foldl', delete)
main = do
    str <- getLine
    let [h, w] = map read $ words $ str :: [Int]
    if h == 0 && w == 0
        then return ()
        else do
            putStr . unlines $ replicate h  $ replicate w '#'
            putStr "\n"
            main

Measured memory_bytes: 4120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

int main(){ 
  string s;
  cin >> s;
  
  int cur = 0;
  for (int i = 0; i < s.size(); i++) {
    int d = s[i] - '0';
    (cur += d ) %= 9;
  }
  if (!cur) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
} 

Measured memory_bytes: 3700
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] facts = {1,2,6,24,120,720,5040,40320};
    int[] P = new int[N];
    int[] Q = new int[N];
    int[] PH = new int[N];
    int[] QH = new int[N];
    int i;
    int a = 0;
    int b = 0;
    for(i=0;i<N;i++){
      P[i] = Integer.parseInt(sc.next());
    }
    for(i=0;i<N;i++){
      Q[i] = Integer.parseInt(sc.next());
    }
    
    for(i=0;i<N;i++){
      for(int j=i+1;j<N;j++){
        if(P[i]>P[j]){
          PH[i]++;
        }
        if(Q[i]>Q[j]){
          QH[i]++;
        }
      }
    }
    
    for(i=0;i<N-1;i++){
      a+=facts[N-2-i]*PH[i];
      b+=facts[N-2-i]*QH[i];
    }
    if(a>b){
      System.out.print(a-b);
    }else{
      System.out.print(b-a);
    }
    System.out.flush();
    
  }
}

Measured memory_bytes: 22740
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        System.out.println(s.nextInt()*s.nextInt());



    }

}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25244
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long int ll;
const int MAX=100000;

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int n;
int indeg[MAX];

void bfs(int s)
{
	queue<int> q;
	q.push(s);
	V[s]=true;
	int u,v;
	
	while(!q.empty())
	{
		u=q.front();q.pop();
		out.push_back(u);
		for(int i=0;i<G[u].size();i++)
		{
			v=G[u][i];
			indeg[v]--;
			if(!V[v]&&indeg[v]==0)
			{
				V[v]=true;
				q.push(v);
			}
		}
	}
	
	return;
}

void topologicalsort()
{
	for(int i=0;i<n;i++)
	{
		indeg[i]=0;
		V[i]=false;
	}
	
	for(int u=0;u<n;u++)
	{
		for(int i=0;i<G[u].size();i++)
		{
			indeg[G[u][i]]++;
		}
	}
	
	for(int u=0;u<n;u++)if(!V[u]&&indeg[u]==0)bfs(u);
	
	for(auto it:out)cout<<it<<endl;
	
	return;
}

int main()
{
	int m;cin>>n>>m;
	int s,t;
	for(int i=0;i<m;i++)
	{
		cin>>s>>t;
		G[s].push_back(t);
	}
	topologicalsort();
	return 0;
}

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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    unordered_map<int, int> indx;
    rep(i, n)
    {
        cin >> a[i];
        indx[a[i]]++;
    }
    int q;
    cin >> q;
    vector<int> b(q), c(q);
    rep(i, q)
    {
        cin >> b[i] >> c[i];
    }

    int sum = 0;
    rep(i, n)
    {
        sum += a[i];
    }

    rep(i, q)
    {
        int t = indx[b[i]];
        sum -= b[i] * t;
        sum += c[i] * t;
        indx[b[i]] = 0;
        indx[c[i]] += t;
        cout << sum << endl;
    }

    return 0;
}


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

int main(){
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0; i < s.size(); i++){
		for(int j = i; j < s.size(); j++){
			bool flag = true;
			for(int k = i; k <= j; k++){
				if(s[k] == 'A' || s[k] == 'C' || s[k] == 'G' || s[k] == 'T'){
					continue;
				}else{
					flag = false;
					break;
				}
			}
			if(flag == true){
				ans = max(ans, j - i + 1);
			}
		}
	}
	cout << ans;
}


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

a=[]
b=[]
for i in range(n):
    a.append(list(map(int, input().split())))

for i in range(m):
    b.append(int(input()))

for i in range(n):
    cnt=0
    for j in range(m):
        cnt+=b[j]*a[i][j]
    print(cnt)


Measured memory_bytes: 6012
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
LL gcd(LL a, LL b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}

LL lcm(LL a, LL b) {
    return a / gcd(a, b) * b ;
}
int main(){
    LL A,B,C,D;cin >> A >> B >> C >> D;
    LL lc = lcm(C,D);
    LL c = B/C - (A-1)/C;
    LL d = (B/D) - (A-1)/D;
    LL l = (B/lc) - (A-1)/lc;
    LL sum = c+d-l;
    cout<<B-A+1-sum<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 100

int main() {
  int n,i,j,u,t,v,T[N][N];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++) {
    for(j = 0 ; j < n ; j++) {
      T[i][j] = 0;
    }
  }

  for(i = 0 ; i < n ; i++) {
    scanf("%d%d",&u,&t);
    u--;
    for(j = 0 ; j < t ; j++) {
      scanf("%d",&v);
      v--;
      T[u][v] = 1;
    }
  }

  for(i = 0 ; i < n ; i++) {
    for(j = 0 ; j < n ; j++) {
      if(j)
        printf(" ");
      printf("%d",T[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2036
#include<iostream>
#include<vector>
using namespace std;
long cnt = 0;
vector<int> G;
void InsertionSort(int A[], int n, int g) {
	for (int i = g; i < n; i++) {
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}
void ShellSort(int A[], int n) {
	for (int h = 1;;) {
		if (h > n)
			break;
		G.push_back(h);
		h = h * 3 + 1;
	}
	for (int i = G.size() - 1; i >= 0; i--) {
		InsertionSort(A, n, G[i]);
	}
}
int main() {
	int n;
	cin >> n;
	int *arr = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	ShellSort(arr, n);
	cout << G.size() << endl;
	for (int i = G.size() - 1; i >= 0; i--) {
		cout << G[i];
		if (i != 0) {
			cout << ' ';
		}
	}
	cout << endl;
	cout << cnt << endl;
	for (int i = 0; i < n; i++) {
		cout << arr[i] << endl;
	}
	delete[] arr;
	return 0;
}


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

int main(){
    string s; cin >> s;
    string t = "keyence";

    int len = s.length(), i, j;
    bool f = false;
    for(i = 0; i < len; i++){
        if(s[i] != t[i]){
            break;
        }
    }
    
    string ne;
    for(int k = 0; k < i; k++) ne += s[k];
    j = 7-i;
    ne += s.substr(len-j, j);
    if(ne == t || s == t) cout << "YES" << endl;
    else cout << "NO" << endl;

    
    return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,m;
	t = 1;
	while(t--) {
	 cin >> n >> m;
	 cout << max(n + m, max(n - m, n * m)) << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n;
	cin >> n;
	priority_queue<int> pi;
	REP(i, n){
		int a;
		cin >> a;
		pi.push(a);
	}
	long long ans = 1;
	int kaburi = 0;
	while (!pi.empty()){
		int a = pi.top(); pi.pop();
		if ((a - kaburi / 4) > 0){
			ans += a - kaburi / 4;
			kaburi++;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  int n = 0;
  for (int i = 0; i < s.size(); i++) 
    if (s[i] != t[i]) n++;
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 3920
#include<stdio.h>
#define N 100
void output(int* a,int numble,int n);

int main()
{
	int n,b;
	scanf("%d",&n);
	int a[N];
	for(int c=0;c<n;c++)
	{
		scanf("%d",a+c);	
	}
	int numble=0;
	for(int i=0;i<n-1;i++)
	{
		int min=i;
		for(int d=i+1;d<n;d++)
		{
			if(a[min]>a[d])
			{
				min=d;
			}
		}
		if(a[min]!=a[i])
		{
			b=a[min];
			a[min]=a[i];
			a[i]=b;
			numble++;
		}
	}
	output(a,numble,n);
	return 0;
}
void output(int* a,int numble,int n)
{
	for(int j=0;j<n;j++)
	{
		if(j!=0)
		{
			printf(" ");
		}
		printf("%d",*(a+j));
		
	}
	printf("\n%d",numble);
	printf("\n");
}


Measured memory_bytes: 2744