akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  string s, t;
  cin >> s >> t;
  int n = sz(s);
  map<char, char> mp1, mp2;
  rep(i, n) {
    if (mp1.count(s[i]) == 0) {
      mp1[s[i]] = t[i];
    } else if (mp1[s[i]] != t[i]) {
      no();
    }
    if (mp2.count(t[i]) == 0) {
      mp2[t[i]] = s[i];
    } else if (mp2[t[i]] != s[i]) {
      no();
    }
  }
  yes();
}

Measured memory_bytes: 916
def main():
    n = int(input())
    A = list(map(int, input().split()))
    max_ans = 10 ** 18
    ans = 0
    if 0 in A:
        print(0)
        exit()

    for i, a in enumerate(A):
        if i == 0:
            ans = a
            continue

        ans = ans * a
        if ans > max_ans:
            print(-1)
            exit()

    if max_ans < ans:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 84628
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int[] array;
    public static void main(String[] args) {
        read();
        solve();
    }

    static void read(){
        array = new int[10];
        for(int i = 0; i < 10; i++){
            array[i] = sc.nextInt();
        }
    }

    static void solve(){
        Arrays.sort(array);
        System.out.println(array[9]);
        System.out.println(array[8]);
        System.out.println(array[7]);
    }

}

Measured memory_bytes: 26088
#
import sys
import math
import numpy as np
import itertools


# いくつか入力
n,m = (int(i) for i in input().split())  
# n行複数列の数をリストに
k = [[int(i) for i in input().split()] for i in range(n)] 

# print(k)
answer = 0
a = [1]*m
#print(a)
for i in range(n):
    b = [0]*m
    for j in range(1,k[i][0]+1):
        b[k[i][j]-1]=1
    for j in range(m):
        if b[j] == 0:
            a[j] = 0



for i in range(m):
    answer += a[i]

print(answer)
         


Measured memory_bytes: 12444
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 998244353
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll ppow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
int a[500];
ll dp[500][100000];

int main(){
	int n;cin>>n;
	rep(i,n){
		scanf("%d",&a[i]);
	}
	dp[0][0]=1;
	ll all=ppow(3,n);
	int cnt=0;
	rep(i,n){
		for(int t=i;t>=0;t--){
			rep(j,cnt+1){
				if(dp[t][j]==0)continue;
				(dp[t+1][j+a[i]]+=dp[t][j])%=MOD;
			}
		}
		cnt+=a[i];
	}
	rep(i,cnt+1){
		if(cnt-i<i){
			rep(j,n+1){
				if(dp[j][i]==0)continue;
				all=(all+MOD-dp[j][i]*ppow(2,n-j)%MOD*3%MOD)%MOD;
			}
		}
		else if(cnt-i==i){
			rep(j,n+1){
				if(dp[j][i]==0)continue;
				all=(all+MOD-dp[j][i]*(ppow(2,n-j)+MOD-2)%MOD%MOD*3%MOD)%MOD;
				all=(all+MOD-dp[j][i]*3%MOD)%MOD;
			}
		}
	}
	cout<<all<<endl;
}

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

constexpr int N = 300, P = 998244353;

int n;
std::string s;

int dp[N + 1][N + 1][N + 1], g[N + 1][N + 1][N + 1];

void chkmax(int &a, int b) {
    a = std::max(a, b);
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    std::cin >> s;
    n = s.length();
    
    std::memset(g, -1, sizeof(g));
    
    g[0][0][0] = 0;
    
    for (int j = 0; j < n; ++j) {
        for (int i = 0; i <= j; ++i) {
            for (int k = 0; k <= j - i; ++k) {
                if (g[i][j][k] < 0)
                    continue;
                chkmax(g[i + 1][j + 1][k], g[i][j][k]);
                chkmax(g[i][j + 1][k + (s[j] == '0')], g[i][j][k] - 1);
                if (j + 2 <= n) {
                    chkmax(g[i + 2][j + 2][k], g[i][j][k] + 1);
                    chkmax(g[i + 1][j + 2][k + (s[j] == '0')], g[i][j][k]);
                    chkmax(g[i + 1][j + 2][k + (s[j + 1] == '0')], g[i][j][k]);
                }
            }
        }
    }
    
    dp[n][n][0] = 1;
    
    int ans = 0;
    for (int i = n - 1; i >= 0; --i) {
        for (int j = i; j <= n; ++j) {
            for (int k = 0; k <= j - i; ++k) {
                if (j < n)
                    dp[i][j][k] += dp[i + 1][j + 1][k];
                if (j > i && k - (s[j - 1] - '0') >= 0)
                    dp[i][j][k] += dp[i + 1][j][k - (s[j - 1] - '0')];
                if (dp[i][j][k] >= P)
                    dp[i][j][k] -= P;
                if (dp[i][j][k] && g[i][j][k] >= 0) {
                    ans += dp[i][j][k];
                    if (ans >= P)
                        ans -= P;
                }
            }
        }
    }
    
    std::cout << ans << "\n";
    
    return 0;
}

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


int main(){
	int N;
		cin >> N;
     vector<string> S(N);
	for (int i = 0; i < N; ++i) {
		cin >> S.at(i);
	 }
	sort(S.begin(), S.end());
	S.erase(unique(S.begin(), S.end()), S.end());
	cout << S.size() << endl;

}


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

int main()
{
    int n;
    cin >> n;
    int a[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++)
            cin >> a[i][j];
        sort(a[i],a[i]+3);
    }
    int m=0;
    for(int i=0;i<n-1;i++)
        for(int j=i+1;j<n;j++){
            if(a[i][0]==a[j][0]&&a[i][1]==a[j][1]&&a[i][2]==a[j][2]){
                if(a[j][0]!=0&&a[j][1]!=0&&a[j][2]!=0)
                    m++;
                    a[j][0]=0,a[j][1]=0,a[j][2]=0;
            }
        }
    cout << m << endl;
    return 0;
}



Measured memory_bytes: 3176
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    string s;
    while(1){
        cin>>s;
        if(s=="#")break;
        set<char> st{'y','u','i','o','p','h','j','k','l','n','m'};
        int hand=0;
        int ans=0;
        for(int i=0;i<s.length();i++){
            if(hand==0){
                if(st.find(s[i])!=st.end())hand=2;
                else hand=1;
            }
            else if(hand==1){
                if(st.find(s[i])!=st.end()){
                    ans++;
                    hand=2;
                }
                else hand=1;
            }
            else if(hand==2){
                if(st.find(s[i])!=st.end()){
                    hand=2;
                }
                else{
                    hand=1;
                    ans++;
                }
            }
        }
        cout<<ans<<endl;
    }
    

//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 3220
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sn = new Scanner(System.in);
		int N = sn.nextInt();
		int K = sn.nextInt();
		int ans = K;
		for(int i = 1; i < N; ++i){
			ans *= K-1;
		}
		System.out.println(ans);
	}
}


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

int main()
{
  int A, B, C;
  int res=0;
  cin >> A >> B >> C;

  res = min(C, B/A);

  cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    set<int> s;
    while(k--){
        int d;
        cin>>d;
        while(d--){
            int temp;
            cin>>temp;
            s.insert(temp);

        }
    }

    // cout<<"F: "<<s.size();

    cout<<( max(0, n -(int)s.size()) )<<endl;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int H=sc.nextInt();
		int W=sc.nextInt();
		System.out.println((N-W+1)*(N-H+1));
	}

}


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


int main(){
	int N;cin>>N;
	vector<int> nos(N);
	for(int i=0;i<N;i++) cin>>nos[i];
	sort(nos.rbegin(),nos.rend());
	nos.push_back(0);
	int total = 0;
	for(int i=0;i<N;i++){
		int cnt = nos[i] - nos[i+1];
		if(cnt&1) total ^= (i+1);
	}
	if(total == 0) cout<<"second"<<endl;
	else cout<<"first"<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*------------------------------------------------------------------------*/

constexpr ll MOD = 1e9 + 7;

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}
void solve() {
    ll x, y;
    std::cin >> x >> y;

    ll n = (2 * y - x) / 3, m = (2 * x - y) / 3;

    if ((x + y) % 3 == 0 && n >= 0 && m >= 0)
        std::cout << modcomb(n + m, n, MOD) << '\n';
    else
        std::cout << 0 << '\n';
}


Measured memory_bytes: 3636
# -*- coding:utf-8 -*-


def max_Heapify(tree, n, i):
    left = (i + 1) * 2 - 1
    right = left + 1

    if left < n and tree[left] > tree[i]:
        largest = left
    else:
        largest = i

    if right < n and tree[right] > tree[largest]:
        largest = right

    if largest != i:
        tree[i], tree[largest] = tree[largest], tree[i]
        max_Heapify(tree, n, largest)


def BuildMaxHeap(tree, n):
    for i in range(n // 2 - 1, -1, -1):
        max_Heapify(tree, n, i)


if __name__ == "__main__":
    n = int(input())
    tree = [int(n) for n in input().split()]
    BuildMaxHeap(tree, n)
    print(" " + " ".join([str(n) for n in tree]))

Measured memory_bytes: 64016
#include<iostream>
#define mod 1000000007
using namespace std;
typedef long long LL;

int y[1005] = {};

bool is_prime(int n) {
	for (int i = 2;i*i <= n;i++)if (n%i == 0)return false;
	return n != 1;
}

void ff(int a) {

	y[2]++;
	y[3]++;
	
		for (int i = 4;i <= a;i++) {
			int b = i;
			for (int j = 2;j*j <= i;j++) {
				
				
					while (b%j == 0) {
						y[j]++;
						b /= j;
					}

				}

			
			if (is_prime(b)&&b!=1)y[b]++;
		}
	
	return;
}

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

	ff(n);

	LL ans = 1;
	for (int i = 0;i <= n;i++) {
		ans *= (y[i] + 1);
		if (ans > mod)ans %= mod;
	}
	cout << ans<< endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int a;
int b;
int c;
int d;
int main() {
	scanf("%d",&a);
	b = a / 100;
	c = a % 100 / 10;
	d = a % 10;
	if (c < b) {
		printf("%d", b * 100 + b * 10 + b);
	}
	else if (c == b) {
		if (d <= c) {
			printf("%d", b * 100 + b * 10 + b);
		}
		else{
			b++;
			printf("%d", b * 100 + b * 10 + b);
		}
	}	
	else {
		b++;
		printf("%d", b * 100 + b * 10 + b);
	}
}

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

int main() {
  int x,y;
  cin>>x>>y;
  bool ans=false;
  for(int i=0;i<=x;i++){
    if(i*2+(x-i)*4==y)
      ans=true;
  }
  if(ans)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

const int inf = 1 << 29;

int A,B,C,N; vector<int> l;

int dfs(int depth,int La, int Lb, int Lc){
  if( depth == N ){
    if( La == 0 || Lb == 0 || Lc == 0){ return inf;}
    else{
      return abs( La - A ) + abs( Lb - B ) + abs( Lc - C ) - 30;}}
      
    
    int r1 = dfs(depth + 1, La + l[depth],Lb,Lc) + 10;
    int r2 = dfs(depth + 1, La, Lb + l[depth] , Lc) + 10;
    int r3 = dfs(depth + 1, La, Lb, Lc + l[depth]) + 10;
    int r4 = dfs( depth + 1, La, Lb, Lc);
    
    return min(min(r1,r2),min(r3,r4));}
    

int main(){
  
  cin >> N >>  A >> B >> C;
  l.resize(N);
  for(int i = 0; i < N; i++){ cin >> l[i];}
  
  cout << dfs(0,0,0,0) << endl;
  return 0;}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#define MOD 1000000007
void input_array(int how_data,int *data);
int get_random(int min, int max);
int factorial(int n);
int fibonacci(int n);
int qsort_09(const int *sys1 , const int *sys2);
int qsort_90(const int *sys1 , const int *sys2);

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


//how_data個の配列data[]に標準入力
//input_array(how_data,data);
void input_array(int how_data,int *data){
    int loop;
    for(loop=0;loop<how_data;loop++){
        scanf("%d",&data[loop]);
    }
}

int get_random(int min, int max){   //指定の範囲から乱数を1つ返すやつ
    //srand((unsigned int)time(0));   //現在時刻で疑似乱数初期化
    rand();rand();rand();rand();    //乱数を空打ち
    return (rand()%(max+1-min))+min;
}


int factorial(int n){//n!のMOD10^9+7を返すやつ
    unsigned long long int ret=1;
    for(int i=1;i<=n;i++)ret=(ret*i)%1000000007;
    return (int)ret;
}

int qsort_09(const int *sys1 , const int *sys2){ //小さいのが上にくるやつ
    //qsort(data,how_data,sizeof(int),(int (*)(const void *,const void *))qsort_09);
    if(*sys1<*sys2){
        return -1;
    }else if(*sys1==*sys2){
        return 0;
    }else{
        return 1;
    }
}

int qsort_90(const int *sys1 , const int *sys2){ //大きいのが上にくるやつ
    //qsort(data,how_data,sizeof(int),(int (*)(const void *,const void *))qsort_90);
    if(*sys1<*sys2){
        return 1;
    }else if(*sys1==*sys2){
        return 0;
    }else{
        return -1;
    }
}
int fibonacci(int n){
    switch(n){
        case 0:return 0;
        case 1:return 1;
        default :return fibonacci(n-1)+fibonacci(n-2);
    }
}



Measured memory_bytes: 128
import sys
from collections import Counter

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N, A = map(int, input().split())
    x = [int(i) for i in input().split()]

    # 3d DP
    max_x = max(x)

    dp = [[[0] * (max_x * N + 1) for j in range(N + 1)]
                                 for i in range(N + 1)]

    dp[0][0][0] = 1

    for i in range(0, N):
        for k in range(0, N + 1):
            for y in range(max_x * N + 1):
                if dp[i][k][y]:
                    dp[i + 1][k][y] += dp[i][k][y]
                    dp[i + 1][k + 1][y + x[i]] += dp[i][k][y]

            # print(dp[i][k])
        # print()

    cnt = 0
    for k in range(1, N + 1):
        for y in range(1, max_x * N + 1):
            if y // k == A and y % k == 0:
                cnt += dp[N][k][y]

    print(cnt)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 63856
import sys
readline = sys.stdin.readline
D = int(readline())
C = list(map(int,readline().split()))
S = [list(map(int,readline().split())) for i in range(D)]
t = [0]*D
for j,s in enumerate(S):
    ansidx = 0
    anssum = 0
    for i,si in enumerate(s,start=1):
        if anssum < si:
            ansidx = i
            anssum = si
    t[j] = ansidx
def score():
    ans = 0
    minus = 0
    last = [0]*26
    for i in range(D):
        ans += S[i][t[i]-1]
        minus = 0
        last[t[i]-1] = i+1
        for j in range(26):
            minus += C[j]*(i-last[j]+1)
        ans -= minus
    return ans
a = score()
import random
for k in range(50000):
    d,q = random.randint(1,D),random.randint(1,26)
    told = t[::]
    t[d-1] = q
    b = score()
    if a > b:
        t = told
    else:
        a = b
for ti in t:
    print(ti)


Measured memory_bytes: 82148
using System;

namespace ABC143_C
{
    class Program
    {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            string input = Console.ReadLine();

            int ans = n;

            for(int index = 0; index < n - 1; index++) {
                string color = input.Substring(index, 1);
                string nextColor = input.Substring(index + 1, 1);

                //同じ色だったら次へ
                if (color != nextColor) continue;

                int j;
                for(j = index; j < n - 1; j++) {
                    nextColor = input.Substring(j + 1, 1);

                    if (color == nextColor) ans--;
                    else break;
                }

                index = j;
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 17376
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>

using namespace std;
using namespace std::chrono;

/*
#define trav(a, v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
*/

typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
ll n,m,k,r;
ll nt;
ll T;


vector<ll> CSP;
vector<ll> CS;
vector<ll> A;


int main()
{

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int c1,c2,c3,c4,c5,c6;
    ll a,b,c,e;

        cin >> n >> k;

        CS.push_back(0);
        CSP.push_back(0);

        for(c1 = 0; c1 < n; c1++){
            cin >> a;
            A.push_back(a);
            CS.push_back(a + CS[c1]);
            CSP.push_back(CSP[c1] + a * (a > 0));
        }

        ll ans = 0;

        for(c1 = 0; c1 <= n - k; c1++){

            ll bos = max(CS[c1+k] - CS[c1] , 0ll);
            ans = max(ans , bos + CSP[n] - (CSP[c1+k] - CSP[c1]));

        }

        cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 2784
#include <stdio.h>
#include <string>
#include <algorithm>
#include <map>
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	int a[3],ma=0,ans=0,sum=0;
	for (int i = 0; i < 3; i++)cin >> a[i];
	bool odd[3];
	for (int i = 0; i < 3; i++) {
		ma = max(ma, a[i]);
		sum += a[i];
	}
	if (3 * ma % 2 == sum % 2)cout<<(3 * ma - sum) / 2<<endl;
	else cout << (3 * (ma + 1) - sum) / 2 << endl;
}


Measured memory_bytes: 256
a1, a2, _, a3, a4, _, _ = map(int, input().split())

ans = 0

# a2をすべて使用して2*2をたくさん作る
ans += a2 * 2
a2 = 0

#(偶奇奇)のときはa1, a3, a4を1つずつ組み合わせておく
#すると(偶偶奇)となる
cnt = 0
if a1 % 2 == 0:
    cnt += 1
if a3 % 2 == 0:
    cnt += 1
if a4 % 2 == 0:
    cnt += 1
if cnt == 1 and a1 * a3 * a4 != 0:
    ans += 6
    a1 -= 1
    a3 -= 1
    a4 -= 1

#(偶偶偶), (偶偶奇), (奇奇奇)のとき
# a1を使用して2*4をたくさん作る
ans += (a1 // 2) * 4
a1 = a1 % 2
# a3を使用して2*4をたくさん作る
ans += (a3 // 2) * 4
a3 = a3 % 2
# a4を使用して2*4をたくさん作る
ans += (a4 // 2) * 4
a4 = a4 % 2
# もしa1, a3, a4が1つずつ余っているなら2*6を1つ作れる
if a1 == 1 and a3 == 1 and a4 == 1:
    ans += 6

print(ans // 2)

Measured memory_bytes: 38384
#include <stdio.h>
#include <string.h>
#define M 1000

int q;
int LCS(char *X, char *Y){
  int Z[M+1][M+1],i,j,x,y;
  x=strlen(X);
  y=strlen(Y);
  //printf("len:%d %d\n",x,y);
  for(i=0;i<q;i++){
    for(j=0;j<q;j++){
      Z[i][j]=0;
    }
  }

  for(i=1;i<=x;i++){
    for(j=1;j<=y;j++){
      if(X[i-1]==Y[j-1]) Z[i][j]=Z[i-1][j-1]+1;
      else if(Z[i-1][j]>=Z[i][j-1]) Z[i][j]=Z[i-1][j];
      else Z[i][j]=Z[i][j-1];
    }
  }
  return Z[x][y];
}

int main(){
  char X[M],Y[M];
  int i,x,y;
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%s",&X[i]);
    //x=strlen(X);
    scanf("%s",&Y[i]);
    //y=strlen(Y);
    //printf("len:%d %d\n",x,y);
    printf("%d\n",LCS(&X[i],&Y[i]));
  }
  
  return 0;
}




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

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

int main() {
    string s;

    cin >> s;
    bool flag = false;
    rep(i, s.length()) {
        if(s[i]=='7')flag = true;
    }

    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3624
n = gets.to_i
p = gets.split.map(&:to_i)

n_swap = 0
for i in 0 ... n-1  do
  if p[i] == i+1
    p[i], p[i+1] = p[i+1], p[i]
    n_swap += 1
  end
end
if p[p.size-1] == p.size
  p[p.size-2], p[p.size-1] = p[p.size-1], p[p.size-2]
  n_swap += 1
end
puts n_swap

Measured memory_bytes: 10116
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n; cin >> n;

  vi normal(n), inverse(n);
  for(int i = 0; i < n; i++){
    int a, b; cin >> a >> b;
    normal[i] = a + b;
    inverse[i] = 1000000000 - a + b;
  }
  sort(normal.begin(), normal.end());
  sort(inverse.begin(), inverse.end());
  cout << max(*normal.rbegin() - *normal.begin(), *inverse.rbegin() - *inverse.begin()) <<endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


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

int main(){
  string S;
  int zero, iti;
  zero = 0;
  iti = 0;
  cin >> S;

  for(int i = 0;i < S.size();i++){
  if(S.at(i) == '0'){
  zero++;
  }
    else{
    iti++;
    }
  }

  if(zero >= iti){
  cout << iti * 2 << endl;
  }
  else{
  cout << zero * 2 << endl;
  }
}

Measured memory_bytes: 512
n = int(input())
t,a = (int(x) for x in input().split())
h = [int(x) for x in input().split()]

best = t - h[0] * 0.006
ans = 0

for i in range(1,n):
	tem = t - h[i] * 0.006
	if abs(a - tem) < abs(a - best):
		best = tem
		ans = i
print(ans + 1)


Measured memory_bytes: 38384
from operator import itemgetter

n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

num = sorted(a)
total = 0
ans = 0

for i in range(n):
  total += num[i][1]
  if total > m:
    ans += num[i][0]*(num[i][1] -(total - m)) 
    break
  ans += num[i][0]*num[i][1] 
  
print(ans)

Measured memory_bytes: 28592
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <sstream>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

char pat[8][8];
char rot[8][8];

main(){
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			cin>>pat[i][j];
		}
	}
	
	for(int i=1;i<=3;i++){
		cout<<i*90<<endl;
		for(int j=0;j<8;j++){
			for(int k=0;k<8;k++){
				rot[j][k]=pat[7-k][j];
				cout<<rot[j][k];
			}
			cout<<endl;
		}
		memcpy(pat,rot,sizeof(rot));
	}
}

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

void solve() {
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A, B;
    A.push_back(0);
    B.push_back(0);

    ll tot = 0;
    rep(i, N) {
        ll a;
        cin >> a;
        tot += a;
        A.push_back(tot);
    }

    tot = 0;
    rep(i, M) {
        ll b;
        cin >> b;
        tot += b;
        B.push_back(tot);
    }

    ll ans = 0;
    ll bs = B.size() - 1;
    for (ll ai = 0; ai < (ll)A.size(); ai++) {
        for (ll bi = bs; bi >= 0; bi--) {
            if (A[ai] + B[bi] <= K) {
                ans = max(ans, ai + bi);
                bs = bi;
                break;
            }
        }
    }

    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 7984
def f(a, b, c, d):
    n = max(1,a//c, b//d)
    while a > c * n or b > d * n : n += 1
    return c * n, d * n
    
def main():
    a, b = 0, 0
    for i in range(int(input())):
        c, d = map(int, input().split())
        a, b = f(a, b, c, d)
    print(a+b)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import heapq

n,m=map(int,input().split())
X=[[] for _ in range(10**5+5)]
for i in range(n):
    a,b=map(int,input().split())
    X[a-1].append(-b)

ans=0
p=[0]*m
heapq.heapify(p)
for i in range(m):
    for j in range(len(X[i])):
        heapq.heappush(p,X[i][j])
    a=heapq.heappop(p)
    ans+=a*-1
print(ans)

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

int main()
{
	int i, N, a[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	
	int ans = 0, count[100001] = {};
	for (i = 1; i <= N; i++) {
		if (a[i] > N) ans++;
		else count[a[i]]++;
	}
	for (i = 1; i <= N; i++) {
		if (count[i] < i) ans += count[i];
		else ans += count[i] - i;
	}
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

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

int main(){
    
    int N,M=0,ans;
    cin>>N;
    vector<pair<int,int>> S(N);
    for(int i=0;i<N;i++){
        int a,b;cin>>a>>b;
        S[i]=make_pair(a,b);
    }
    for(int i=0;i<N;i++){
        if(S[i].first>M){
            ans=i;
            M=S[i].first;
        }
    }
    cout<<S[ans].first+S[ans].second<<endl;
}


Measured memory_bytes: 1024
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "string"

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> vec(n);
	for (int i = 1; i <= n; i++) {
		//iに何回kをかけるとk以上になるか
		int p = i;
		int tmp = 0;
		while (p < k) {
			p *= 2;
			tmp++;
		}
		vec[i-1] = tmp;
	}
	double ans = 0;
	rep(i, n) {
		int tmp = 1;
		rep(j, vec[i]) tmp *= 2;
		ans += (double)1 / (n*tmp);
	}
	cout << fixed << setprecision(10);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
x=int(input())
import math
def fl(x):
    digits = 10
    form = '%.'+str(digits-1)+'e'
    return float((form % x))

for a in range(300):
    if a**5 >= x :
        B=a**5-x
        b = math.pow(B, 1.0/5.0)
        #print(a,b,B)
        if fl(b).is_integer()==True:
            b=int(b)
            print(a,b)
            break
    else:
        B=x-a**5
        b=math.pow(B, 1.0/5.0)
        #print(a,b,B)
        if fl(b).is_integer()==True:
            b=int(b)
            print(a,-b)
            break

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

using i64 = long long;

#define dbg(x) cerr << "[" #x << " : " << x << "]\n"

const int mod = (int)1e9+7;

int main()
{
    i64 n, m;
    i64 a[200000];
    scanf("%lld%lld", &n, &m);
    for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
    i64 lcm = a[0]/2;
    i64 ans = 0;
    for(int i = 1; i < n; i++) {
        i64 g = __gcd(lcm, a[i]/2);
        lcm = (lcm*a[i]/2)/g;
        if(lcm > m) {
            printf("0\n");
            return 0;
        }
    }
    for(int i = 0; i < n; i++) {
        if(lcm % a[i] == 0) {
            puts("0");
            return 0;
        }
    }
    ans = ((m/lcm)+1)/2;
    printf("%lld\n", ans);
}


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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -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; }

int main()
{
    int h, w, d, q;
    cin >> h >> w >> d;

    vector<vector<tuple<int, int, int>>> x(d);
    int tmp;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> tmp;
            x[tmp%d].push_back(make_tuple(tmp, i+1, j+1));
        }
    }

    cin >> q;
    vector <int> l(q), r(q);
    for (int i = 0; i < q; i++) cin >> l[i] >> r[i];

    for (int i = 0; i < d; i++) sort(x[i].begin(), x[i].end());

    vector<vector<int>> sum(d);

    for (int i = 0; i < d; i++) {
        sum[i].push_back(0);
        tmp = 0;
        for (int j = 0; j < int(x[i].size()); j++) {
            sum[i].push_back(abs(get<1>(x[i][j+1]) - get<1>(x[i][j])) + abs(get<2>(x[i][j+1]) - get<2>(x[i][j])) + tmp);
            tmp += abs(get<1>(x[i][j+1]) - get<1>(x[i][j])) + abs(get<2>(x[i][j+1]) - get<2>(x[i][j]));
        }
    }
    /*
    for (int i = 0; i < d; i++) {
        cout << i << " : ";
        for (int j = 0; j  < sum[i].size(); j++) {
            cout << sum[i][j] << " ";
        }
        cout << endl;
    }
    */
    for (int i = 0; i < q; i++) {
        tmp = r[i]%d;
        int r_idx = (r[i]-1)/d;
        //cout << r_idx << endl;
        int l_idx = (l[i]-1)/d;
        //cout << l_idx << endl;
        cout << sum[tmp][r_idx] - sum[tmp][l_idx] << endl;
    }


    return 0;
}



Measured memory_bytes: 11136
a,b,c,k=map(int,input().split())
if k<=a:
	print(k)
elif a<k and k<=a+b:
	print(a)
elif a+b<k and k<=a+b+c:
	print(a-(k-a-b))
elif a+b+c<=k:
	print(a-c)

Measured memory_bytes: 9188
import java.util.Scanner;
public class Main{
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
String line = sc.nextLine();
String answer = "";
int length = line.length();
for(int i = 0;i<length;i++){
  char ch = line.charAt(i);
if(Character.isLowerCase(ch)){
  answer+=Character.toUpperCase(ch);
}
else{
  answer+=Character.toLowerCase(ch);
}
}
  System.out.println(answer);
}
}



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

using namespace std;

int main(){
	int N, M, X;

	scanf("%d %d %d", &N, &M, &X);

	for(int a = 0; a < M; a++){
		scanf("%d", &N);

		if(X < N){
			printf("%d\n", (M - a < a ? M - a : a));
			break;
		}
	}
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
int main() {
  int n;cin>>n;
  int ans=0;
  if(n<105){
    ans=0;
  }else if(n==105){
    ans=1;
  }else if(n>105){
    ans++;
    int top=(n%2==0)?n+1:n;
    for(int i=107;i<n+1;i+=2){
      int cnt=0;
      for(int j=1;j<=i;j+=2){
        if(i%j==0){
          cnt++;
        }
      }
      if(cnt==8){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;

const int N = 200100;

int head[N];
int cnt;
struct Edge{
    int v;
    int next;
};
Edge edge[N];
void add(int u, int v) {
    edge[cnt].v = v;
    edge[cnt].next = head[u];
    head[u] = cnt++;
    edge[cnt].v = u;
    edge[cnt].next = head[v];
    head[v] = cnt++;
}
int n;
int color[N];
bool vis[N];
int len;
bool f;
void dfs(int v, int l) {
    if(v == n) {
        len = l;
        f = true;
        return;
    }
    for(int i = head[v]; i != -1; i = edge[i].next) {
        if(!vis[edge[i].v]) vis[edge[i].v] = true, dfs(edge[i].v, l + 1);
        if(f) {
            if(l <= len / 2) color[v] = 1;
            else color[v] = -1;
            return;
        }
    }
}

void paint(int v, int cl) {
    for(int i = head[v]; i != -1; i = edge[i].next) {
        if(!color[edge[i].v]) {
            color[edge[i].v] = cl;
            paint(edge[i].v, cl);
        }
    }
}

int main() {
    cnt = 0;
    memset(head, -1, sizeof(head));
    int a, b;
    cin >> n;
    for(int i = 1; i < n; i++) {
        cin >> a >> b;
        add(a, b);
    }
    color[1] = 1; color[n] = -1;
    vis[1] = true;
    dfs(1, 0);
    for(int i = 1; i <= n; i++) {
        if(color[i]) paint(i, color[i]);
    }
    int fennec = 0, snuke = 0;
    for(int i = 1; i <= n; i++) {
        if(color[i] == 1) fennec++;
        else if(color[i] == -1) snuke++;
    }
    if(fennec > snuke) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
    return 0;
}


Measured memory_bytes: 7808
#include <math.h>
#include <iostream>

int main()
{
	int allCaseCount, difficultCaseCount;
	std::cin >> allCaseCount >> difficultCaseCount;

	int expectedTryCount = 1;
	for (int i = 0; i < difficultCaseCount; i = i + 1) { expectedTryCount *= 2; }

	std::cout << expectedTryCount*(allCaseCount * 100 + difficultCaseCount * 1800);

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int s = -1;
    for(int i = 0; i < str.length(); i++){
      if(str.charAt(i) == 'A'){
        s = i;
        break;
      }
    }
 
    int t = -1;
    for(int i = str.length() - 1; i >= 0; i--){
      if(str.charAt(i) == 'Z'){
        t = i;
        break;
      }
    }
 
    System.out.println((t - s) + 1);
  }
}

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

string add(string a, string b) {

	int za = a.size();
	int zb = b.size();
	vector<int>v;

	for (int i = 0; i < max(za, zb); i++) {
		if (i < min(za, zb)) {
			int c = za - i - 1;
			int d = zb - i - 1;
			v.push_back((a[za - i - 1] - '0') + (b[zb - i - 1] - '0'));
		}
		else {
			if (za < zb)v.push_back(b[zb - i - 1] - '0');
			else v.push_back((a[za - i - 1]) - '0');
		}
	}
	int z = v.size();
	for (int i = 0; i < v.size(); i++) {
		if (i != z - 1 && v[i] >= 10) {
			v[i] -= 10;
			v[i + 1]++;
		}
	}
	string ans = "";
	for (int i = z - 1; i > -1; i--) {
		int x = v[i];
		string c = to_string(x);
		ans += c;
	}
	return ans;
}

int main() {
	string a;
	while (cin >> a) {
		string sa, sb, sc;
		vector<string>VA,VB,VC;
		
		int h = 0;
		for (int i = 0; i < a.size(); i++) {
			if (a[i] == '+')h = 1;
			else if (a[i] == '=')h = 2;
			else {
				if (h == 0)sa.push_back(a[i]);
				else if (h == 1)sb.push_back(a[i]);
				else sc.push_back(a[i]);
			}
		}

		for (int i = 0; i <= 9; i++) {
			string A, B, C;
			for (int j = 0; j < sa.size(); j++) {
				if (sa[j] == 'X') {
					char x = '0' + i;
					A.push_back(x);
				}
				else A.push_back(sa[j]);
			}

			for (int j = 0; j < sb.size(); j++) {
				if (sb[j] == 'X') {
					char x = '0' + i;
					B.push_back(x);
				}
				else B.push_back(sb[j]);
			}

			for (int j = 0; j < sc.size(); j++) {
				if (sc[j] == 'X') {
					char x = '0' + i;
					C.push_back(x);
				}
				else C.push_back(sc[j]);
			}
			if ((A[0] != '0'||A.size()==1)&&(B[0] != '0'||B.size()==1)&&(C.size()==1||C[0] != '0')) {
				VA.push_back(A);
				VB.push_back(B);
				VC.push_back(C);
			}
		}
		int ans = -1;
		for (int i = 0; i < VA.size(); i++) {
			if (add(VA[i], VB[i]) == VC[i]) {
				if (VA.size() == 10)ans = i;
				else ans = i + 1;
			}
		}
		if (ans == -1)cout << "NA" << endl;
		else cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3180
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io;
use std::str::FromStr;
use std::iter::FromIterator;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::mem::{replace, swap};


// abcde
fn read_string() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    line
}

// -3.2
fn read_as_primitive<T: FromStr>() -> T {
    let s = read_string();
    s.trim().parse().ok().expect("failed to parse input")
}

// 1 -3 0 999
fn read_as_collection<U: FromStr, T: FromIterator<U>>() -> T {
    let s = read_string();
    s.trim().split_whitespace().map(|s| s.parse().ok().expect("failed to parse")).collect()
}

// #.#.###..
fn read_as_chars<T: FromIterator<char>>() -> T {
    let s = read_string();
    s.trim().chars().collect()
}

// 1 abc
fn read_as_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let s = read_string();
    let elems: Vec<_> = s.trim().split_whitespace().collect();
    (
        elems[0].parse().ok().expect("failed to parse"),
        elems[1].parse().ok().expect("failed to parse"),
    )
}

// 1.5 -2 abc
fn read_as_triple<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let s = read_string();
    let elems: Vec<_> = s.trim().split_whitespace().collect();
    (
        elems[0].parse().ok().expect("failed to parse"),
        elems[1].parse().ok().expect("failed to parse"),
        elems[2].parse().ok().expect("failed to parse"),
    )
}

fn main() {
    let n: i32 = read_as_primitive();
    let mut sum = 0;
    let mut max_val = 0;
    for _ in 0..n {
        let x: i32 = read_as_primitive();
        max_val = max(max_val, x);
        sum += x;
    }
    let ans = sum - max_val / 2;
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define ll long long int
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int mod = 1000000007;

ll desc(ll x, ll y)
{
    return x > y;
}

int main() {
    fastIO
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double max_area = (w * h) / 2.0;

    if (w / 2 == x && h / 2 == y)
        cout <<setprecision(10)<< max_area << " " << 1 <<endl;
    else
        cout << setprecision(10) <<max_area << " " << 0 << endl;


    return 0;
}

Measured memory_bytes: 256
l = [int(_) for _ in input().split()]

ans = float('inf')
for i in range(3):
    for j in range(3):
        if j == i:
            continue
        for k in range(3):
            if k == i or k == j:
                continue
            cost = abs(l[j] - l[i]) + abs(l[k] - l[j])
            ans = min(ans, cost)
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n, m, a[200000], b[200000];
    cin >> n >> m;
    for(int i=0; i<m; i++) cin >> a[i] >> b[i];

    int tmpo[200000]={}, tmpn[200000]={};
    for(int i=0; i<m; i++){
        if(a[i] == 1){
            if(tmpo[b[i]]) continue;
            tmpo[b[i]]++;
        }
        if(b[i] == 1){
            if(tmpo[a[i]]) continue;
            tmpo[a[i]]++;
        }
        if(a[i] == n){
            if(tmpn[b[i]]) continue;
            tmpn[b[i]]++;
        }
        if(b[i] == n){
            if(tmpn[a[i]]) continue;
            tmpn[a[i]]++;
        }
    }

    bool pos = false;
    for(int i=0; i<200000; i++){
        if(tmpo[i] and tmpn[i]) pos = true;
    }

    cout << (pos ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}


Measured memory_bytes: 3328
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    s = input()
    if s == 'AC':
        ac += 1
    elif s == 'WA':
        wa += 1
    elif s == 'TLE':
        tle += 1
    else:
        re += 1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))

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

int main(){
    int r, g, b;
    cin >> r >> g >> b;
    if(!((r * 100 + g * 10 + b) % 4)){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import itertools

N = int(input())
digit = 3
ans = 0
while True:
    for t in itertools.product((3, 5, 7), repeat=digit):
        if set(t) != {3, 5, 7}:
            continue
        x = int(''.join(map(str, t)))
        if x > N:
            print(ans)
            exit()
        ans += 1
    digit += 1


Measured memory_bytes: 3060
function Main(input) {
    rotate = str => str.slice(1) + str[0];
    f = false;
    input = input.split("\n");
    for (i = 0; i < input[0].length; i++)
        if ((input[0] = rotate(input[0])) == input[1]) {
            f = true;
            break;
        }
    console.log(f ? "Yes" : "No");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const ll INF = (1 << 30) - 1;

int main() {
    int N;
    cin >> N;
    vector<int> heights;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        heights.emplace_back(tmp);
    }

    vector<ll> dp(N, INF);
    dp.at(0) = 0;
    dp.at(1) = abs(heights.at(1) - heights.at(0));
    for (int i = 2; i < N; i++) {
        ll next_h = heights.at(i);
        ll min_cost = min(
            dp.at(i - 2) + abs(next_h - heights.at(i - 2)),
            dp.at(i - 1) + abs(next_h - heights.at(i - 1))
        );
        dp.at(i) = min_cost;
    }
    cout << dp.at(N - 1) << "\n";
}

Measured memory_bytes: 1528
#include <iostream>
using namespace std;
int n,g[100][100],c[100],f[100],e[100],t=1;
void dfs(int now){
  c[now]=1;
  f[now]=t;
  t++;
  for(int i=0;i<n;i++) if(g[now][i]&&c[i]!=1){
      dfs(i);
      t++;
    }
  e[now]=t;
}
int main(){
 
  int a,b,tmp;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    for(int j=0;j<b;j++){
      cin>>tmp;
      g[a-1][tmp-1]=1;
    }
  }
  for(int i=0;i<n;i++) if(c[i]!=1){
      dfs(i);
      t++;
    }
 
  for(int i=0;i<n;i++) cout<<i+1<<" "<<f[i]<<" "<<e[i]<<endl;
 
  return 0;
 
}


Measured memory_bytes: 3112
#include<stdio.h>
#define N 1000000000000000000

int main(void)
{
  int X,Y;

  scanf("%d",&X);
  scanf("%d",&Y);

  if(X % Y != 0){
    for( int i = 0 ; i <= N ; i++ ){
      if((i % Y != 0)&&(i >= X)&&(i >= Y)){
        if(i % X == 0){
          printf("%d",i);
          break;
        }
      }
    }
  }
  else{
    printf("%d",-1);
  }

  return 0;

}

Measured memory_bytes: 128
/* **********************************************

  File Name: main.cpp

  Auther: zhengdongjian@tju.edu.cn

  Created Time: 2015??´08???29??\ ????????? 10??¶18???38?§?

*********************************************** */
#include <bits/stdc++.h>
using namespace std;

const double EPS = 1e-12;

int k;
double p, e, t;
double dfs(double l, double r, double pre, int dep) {
	//printf("dfs %f, %f, %f, %d\n", l, r, pre, dep);
	if (dep == k) {
		return fabs(t - (l + r) * 0.5) < e + EPS ? 0.0 : pre;
	}
	if (fabs(pre) < EPS) {
		return 0.0;
	}
	if (l > t + e || r < t - e) return pre;

	double h = (l + r) * 0.5;
	if (h > t) {
		//cout << "p = " << p << endl;
		return dfs(h, r, pre * p, dep + 1) + dfs(l, h, pre * (1.0 - p), dep + 1);
	} else {
		return dfs(l, h, pre * p, dep + 1) + dfs(h, r, pre * (1.0 - p), dep + 1);
	}
}

int main() {
	double r, l;
	while (cin >> k >> l >> r) {
		cin >> p >> e >> t;
		double ans = 1.0 - dfs(l, r, 1.0, 0);
		cout << fixed << setprecision(6) << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1292
rule = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}

while True:
    try:
        line = raw_input()
        nums = [rule[c] for c in list(line)] + [0]
        print sum(map(
            lambda (a, b): -a if a < b else a,
            [(a, b) for a, b in [nums[i:i+2] for i in range(len(line))]]))

    except EOFError:
        break

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

int main(void) {
	string s, t; cin >> s >> t;

	sort(s.begin(),s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	return 0;
}



Measured memory_bytes: 256