akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n);
	string s; cin >> s;
	LL red = 0, blue = 0;
	rep(i, 0, s.length()) {
		if(s[i] == 'R')	red++;
		else	blue++;
	}
	if(red > blue)	puts("Yes");
	else	puts("No");
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#include <tuple>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n;
  cin >> n;
  vector< string > s(n);
  int p[n];
  for(int i = 0; i < n; i++){
    cin >> s[i] >> p[i];
  }

  vector< tuple< string, int, int > > tp(n);
  for(int i = 0; i < n; i++){
    tp[i] = make_tuple(s[i], -p[i], i);
  }
  sort(tp.begin(), tp.end());

  string buf;
  for(int i = 0; i < n; i++){
    buf += to_string(get< 2 >(tp[i]) + 1) + "\n";
  }

  cout << buf;

  return 0;
}


Measured memory_bytes: 384
s=input().upper()
c=0
largest=0


for i in range(len(s)-1):
    if s[i] == "R":
        if c == 0:
            c+=1
        if s[i] == s[i+1]:
            c+=1
        #print("dasd",c,i,len(s))
    else:
        #print("asd", c)
        if c > largest:
            largest=c
        c=0
    if i + 2 == len(s):
        if s[i+1] == "R" and c == 0:
            c+=1
        #print("asdfasd")
        if c > largest:
            largest=c

print(largest)


Measured memory_bytes: 9048
#include <iostream>
int main(){
    int n, m;
    std::cin >> n >> m;
    int vals[n];
    int i;
    for(i=0;i<n;i++)vals[i] = -1;
    for(i=0; i < m;i++){
        int s, c;
        std::cin >> s >> c;
        if((vals[s-1]!=-1)&&(vals[s-1]!=c)){
            std::cout << -1 << std::endl;
            return 0;
        }
        vals[s-1] = c;
    }
    if((n>1)&&(vals[0]==0)){
        std::cout << -1 << std::endl;
        return 0;
    }
    if(vals[0]==-1){
        vals[0] = (n==1) ? 0 : 1;
    }
    std::cout << vals[0];
    for(i=1;i<n;i++){
        if(vals[i]==-1)vals[i]=0;
        std::cout << vals[i];
    }
    std::cout << std::endl;
    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char cla[9][16];
	int mor[9], aft[9];
	int i;
	
	for (i = 0; i < 9; i++){
		scanf("%s %d %d", cla[i], &mor[i], &aft[i]);
	}
	
	for (i = 0; i < 9; i++){
		printf("%s %d %d\n", cla[i], mor[i] + aft[i], (mor[i] * 200) + (aft[i] * 300));
	}
	
	return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;

    int lary[n];
    rep(i,n) cin >> lary[i];
    sort(lary, lary+n);
    ll ans = 0;

    rep(i,n-1)
    {
        REP(j, i+1, n)
        {
            int ok = j;
            int ng = n;

            while(abs(ok-ng)>1)
            {
                int mid = (ok+ng)/2;
                if (lary[mid] < lary[i]+lary[j])
                {
                    ok = mid;
                }
                else
                {
                    ng = mid;
                }
            }
            // cout << "i: " << i << endl;
            // cout << "j: " << j << endl;
            // cout << "ok_iter: " << ok << endl;
            // cout << "ok_num: " << lary[ok] << endl;

            ans += max(0, ok-j);
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <stdio.h> 
 
  int main(){ 
     int a, b, d, r; 
     double f; 
     scanf("%d %d", &a, &b); 
     d=a/b; 
     r=a%b; 
     f=(double)a/(double)b; 
     printf("%d %d %f\n", d, r, f); 
     return 0; 
 } 



Measured memory_bytes: 2044
N = int(input())
X = list(map(int, input().split()))
XX = list(X)

X.sort()
left = X[N // 2 - 1]
right = X[N // 2]

if left == right:
    for i in range(N):
        print(left)
    exit()

for x in XX:
    if x <= left:
        print(right)
    else:
        print(left)


Measured memory_bytes: 25744
#include <cstdio>
#include <deque>

using namespace std;

typedef struct
{
  /** Switch */
  int sw;
  /** Floor */
  int fl;
  /** Result Counter */
  int rc;
} yamashitam;

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  deque< yamashitam > q;
  int i, j;

  for ( ; ; )
  {
    int m[ 2 ][ 128 ] = { { 0 } };
    int d[ 2 ][ 128 ] = { { 0 } };
    yamashitam s;
    int n;

    scanf ( "%d", &n );
    if ( !n ) break ;

    for ( j = 0; j < 2; ++j )
    for ( i = 0; i < n; ++i )
    {
      scanf ( "%d", &d[ j ][ i ] );
    }
    q.clear ( );

    s.sw = 0;
    s.fl = 0;
    s.rc = 0;
    q.push_front ( s );
    s.sw = !s.sw;
    q.push_front ( s );

    while ( !q.empty ( ) )
    {
      s = q.back ( );
      q.pop_back ( );

      if ( s.fl < 0 || s.fl >= n  )   continue ;

      switch ( d[ s.sw ][ s.fl ] )
      {
        case 0:
          break ;
        case 1:
          while ( d[ s.sw ][ s.fl ] == 1 )
            ++s.fl;
          --s.fl;
          break ;
        case 2:
          while ( d[ s.sw ][ s.fl ] == 2 )
            --s.fl;
          break ;
      }
      if ( m[ s.sw ][ s.fl ] )  continue ;
      if ( s.fl == n - 1 )      break ;

      m[ s.sw ][ s.fl ] = 1;
      s.sw = !s.sw;
      ++s.rc;
      q.push_front ( s );
      ++s.fl;
      q.push_front ( s );
      ++s.fl;
      q.push_front ( s );
    }

    if ( s.fl == n - 1 )
    {
      printf ( "%d\n", s.rc );
    }
    else
    {
      puts ( "NA" );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
using namespace std;

const int MAXN = 1e5 + 100;

int dp[MAXN];
int N, K;
int c[MAXN];

int main() {
    ios::sync_with_stdio(false);
    cin >> N >> K;
    for (int i = 1; i <= N; ++i) {
        cin >> c[i];
        dp[i] = 0x3f3f3f3f;
    }
    dp[1] = 0;
    for (int i = 2;i <= N; ++i) {
        for (int j = 1;j <= K; ++j) {
            if (i > j) {
                dp[i] = min(dp[i], dp[i - j] + abs(c[i] - c[i - j]));
            }
        }
    }
    cout << dp[N];
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mem(x,v) memset(x,v,sizeof(x))
#define Rep(i,a,b) for(int i=(a);i<=int(b);++i)
#define rep(i,a,b) for(int i=(a);i<int(b);++i)
#define Dep(i,a,b) for(int i=(a);i>=int(b);--i)
#define gc getchar
#define pc putchar
#define fi first
#define se second
inline ll read(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);pc('\n');}
inline void wri(ll x){write(x);pc(' ');}
int n,m,a[1<<11][1<<11];
#define lowbit(x) ((x)&-(x))
int main(){
	n = read(),m = read();
	int h = max(n,m);
	rep(i,1,1<<h)
		rep(j,1,1<<h)
			if(lowbit(i)==lowbit(j))
				a[i][j] = 1;
		rep(i,1,1<<n){
			rep(j,1,1<<m){
				pc(a[i][j]+'0');
			}puts("");
		}
	return 0;
}




Measured memory_bytes: 11700
#include<stdio.h>
int main(void)
{
  int i,n;
  double x,sum=0;
  //char   u[10];
  char s[3];
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){      
    scanf("%lf %s\n",&x,s);  
    if(s[0]=='B')x=x*380000;
    sum = sum + x;
  }
  
  printf("%f",sum);

  return(0);
}

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

int main() {
	string S;
	cin >> S;
	int N = S.size();
	int ans = 99999, Integer = 753;
	for (int i = 0; i < N - 2; i++) {
		int a = S.at(i) - 48, b = S.at(i + 1) - 48, c = S.at(i + 2) - 48;
		int num = a * 100 + b * 10 + c;
		if (ans > abs(Integer - num))ans = abs(Integer - num);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def city_saver(a, b):
    monster = 0
    for i in range(len(b)):
        monster += min(a[i], b[i])
        if(a[i]<b[i]):
            monster += min(b[i]-a[i], a[i+1])
            a[i+1] -= min(b[i]-a[i], a[i+1])
    return monster

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

if __name__ == "__main__":
    main()


Measured memory_bytes: 18476
#include <stdio.h>
int main(void)
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a<b)
    {
        printf("a < b\n");
    }
    else if(a>b)
    {
        printf("a > b\n");
    }
    else printf("a == b\n");
    return 0;
}


Measured memory_bytes: 2612
# -*- coding: utf-8 -*-
"""
B - Bite Eating
https://atcoder.jp/contests/abc131/tasks/abc131_b

"""
import sys


def solve(N, L):
    apples = sorted([a  for a in range(L, L+N)], key=lambda x: abs(x))
    return sum(apples[1:])


def main(args):
    N, L = map(int, input().split())
    ans = solve(N, L)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll n;
ll dp[maxn];
ll a[maxn];
ll k;
int main()
{
    gbtb;
    cin>>n>>k;
    repd(i,1,n)
    {
        cin>>a[i];
    }
    dp[1]=0;
    dp[0]=0;
    repd(i,2,n)
    {
        dp[i]=inf;
    }
    repd(i,2,n)
    {
        for(int j=i-1;j>=max(1ll,i-k);j--)
        {
            dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
        }
    }
    cout<<dp[n];
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}

Measured memory_bytes: 5196
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d",&n);
    int a=n/1000,b=(n/100)%10,c=(n/10)%10,d=n%10;
    if(a==b||b==c||c==d)
        printf("Bad\n");
    else
        printf("Good\n");
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}

int n,k;
int dp[110][110000];
int sdp[110000];
int num[110000];

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  
  cin>>n>>k;

  int it=0;
  for(int i=1;i<=n;){
    int j=n/i;
    if(i<=j){
      num[it++]=1;
      i++;
    }else{
      num[it++]=n/j-i+1;
      i=n/j+1;
    }
  }

  dp[0][0]=1;
  rep(i,k){
    memset(sdp,0,sizeof(sdp));
    rep(j,it+1) sdp[j+1]=Madd(sdp[j],dp[i][j]);
    rep(j,it) dp[i+1][j]=Mmul(sdp[it-j],num[j]);
  }

  

  int ans=0;
  rep(j,it+1) ans=Madd(ans,dp[k][j]);

  cout<<ans<<endl;



}

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

int main() {
  int N, K;
  cin >> N >> K;
  double sum = 0.0;
  for (int i=1; i <= N; i++) {
    int num = i;
    double twp = 1.0 / N;
    while (num < K) {
      num *= 2;
      twp /= 2;
    }
    sum += twp;
  }
  cout << fixed << setprecision(12) << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define max_n 1000000

using namespace std;

void solve()
{
	ll n,m;
	cin>>n>>m;
	ll a[n],tot=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];tot+=a[i];
	}
	sort(a,a+n);
	if((double)a[n-m]<(double)tot/(4*m))
	{
		cout<<"No"<<endl;
	}
	else cout<<"Yes"<<endl;
}

int32_t main() 
{ 

	IOS	
	ll T=1;
	// cin>>T;
	for(ll i=1;i<=T;++i)
	{		
		// cout<<"Case #"<<i<<": ";
    	solve();
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

ll n, k;

ll cube(ll x) {return x*x*x;}

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

    ll ans = cube(n/k);
    if (k%2 == 0)
        ans += cube((n+k/2)/k);

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
    static final long MOD = -10000000000007L;
    //static final long MOD = 998244353L;
    static final int INF = 50000000;
    static final int NINF = -500000000;
    
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        
        String ans = "";
        int K = sc.ni();
        for (int i = 0; i < K; i++)
        	ans += "ACL";
        pw.println(ans);
        
        
        pw.close();
    }
    
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int ni() {
            return Integer.parseInt(next());
        }
 
        long nl() {
            return Long.parseLong(next());
        }
 
        double nd() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

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

int main(){
	int n, s;
	vector<int> a;
	cin >> n;
	a.resize(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n / 2; ++i){
		s = a[i];
		a[i] = a[n-1-i];
		a[n-1-i] = s;
	}
	for(int i = 0; i < n; i++){
		if(i == n - 1) cout << a[i] << endl;
		else cout << a[i] << " ";
	}
	return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

int main()
{
    int n,x,t;
    cin >> n >> x >> t;
    if(n%x==0)
    {
        cout << n/x * t;
    }
    else
    {
        cout << (n/x+1) * t;
    }
    
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define leer(argument) cin>>argument
#define esc(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;

#include <iostream>
using namespace std;

int main(void){
  
  char a, b, c, d; leer(a>>b>>c>>d);

	if( a == b || b == c || c == d){

      cout << "Bad" << endl;
      
    }else{
      
      cout << "Good" << endl;
      
    }

return 0;

}

Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if i*500+j*100+k*50==X:
        count +=1
print(count)

Measured memory_bytes: 3316
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using ll = long long;
using namespace std;

constexpr int n_max = 20;
int main() {
    while (true) {
        array<char, n_max+1> s;
        scanf("%s", s.data());
        if (s[0] == '#') break;
        int n = strlen(s.data());
        int cnt = 0;
        vector<string> acc;
        repeat (modified, 1 << n) {
            array<bool, 26> used = {};
            used[0] = true;
            bool invalid = false;
            repeat (i, n) {
                char c = s[i];
                if (modified & (1 << i)) {
                    if (c == 'z') {
                        invalid = true;
                        break;
                    } else {
                        c += 1;
                    }
                }
                if (not used[c-'a']) {
                    used[c-'a'] = true;
                    c -= 1;
                }
                if (s[i] != c) {
                    invalid = true;
                    break;
                }
            }
            if (invalid) continue;
            string t;
            repeat (i, n) {
                char c = s[i] + bool(modified & (1 << i));
                t += c;
            }
            cnt += 1;
            acc.push_back(t);
            whole(sort, acc);
            if (acc.size() == 11) acc.erase(acc.begin() + 5);
        }
        whole(sort, acc);
        printf("%d\n", cnt);
        for (string t : acc) {
            printf("%s\n", t.c_str());
        }
    }
    return 0;
}

Measured memory_bytes: 2752
def main():
	N = int(input())
	S = input()
	w = 0
	b = 0
	stack = []
	if S[0] == ".":
		stack.append(0)

	before = S[0]
	current = 0
	for i, c in enumerate(S):
		if c == ".":
			w += 1
		else:
			b += 1
		if c != before:
			stack.append(current)
			before = c
			current = 1
		else:
			current += 1
	stack.append(current)
	if len(stack) %2 != 0:
		stack.append(0)

	ans = min(w, b)
	w_change = 0
	b_change = b
	while stack:
		current_w = stack.pop()
		current_b = stack.pop()
		w_change += current_w
		b_change -= current_b
		ans = min(ans, w_change+b_change)

	print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 5096
using System;

	
	public class Class1
	{
		static void Main()
		{
		 string abc=Console.ReadLine();
		 string[] abcArray=abc.Split();
		 int a=int.Parse(abcArray[0]);
		 int b=int.Parse(abcArray[1]);
		  int c=int.Parse(abcArray[2]);
		  int s=0;
		  
		  if(a<b)
		 {
		  	if(a>c)//c<a<b
		  	{
		  		s=a;
		  		a=c;
		  		c=b;
		  		b=s;
		  		
		  	}
		  	else if(c<b)//a<c<b
		  	{
		  		s=c;
		  		c=b;
		  		b=s;
		  		
		  	}
		  	
		  	
		 }
		  else if(a>b)//b<a
		  {
		  	if(c<b)//c<b<a
		  	{
		  		s=c;
		  		c=a;
		  		a=s;
		  		
		  	}
		  	else if(a<c)//b<a<c
		  	{
		  		s=b;
		  		b=a;
		  		a=s;
		  	
		  	}
		  	else //b<c<a
		  	{
		  		s=b;
		  		b=c;
		  		c=a;
		  		a=s;
		  		
		  		
		  	}
		  		
		  }
		  
		  	
		 
		 	Console.WriteLine("{0} {1} {2}",a,b,c);
		 
		
		}
	}

Measured memory_bytes: 9064
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int n, k;
  cin >> n >> k;
  int ans = LLONG_MAX;
  int p = n / k;
  ans = min(ans, abs(n - p * k));
  p++;
  ans = min(ans, abs(n - p * k));
  cout << ans << endl;
  return 0;
}


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


int main()
{
   long x,y;
   cin >> x >> y;
   if((y>=2*x) && (y<=4*x) && (y%2==0))
   {
   	cout << "Yes";
   }
   else
   {
   	cout << "No";
   }
   
   
   return 0;
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N, M, X; cin >> N >> M >> X;
    vector<bool> A(M, false); 
    REP(i, M) {
        int ai; cin >> ai;
        A[ai] = true;
    } 
    int ans = 0;
    FOR(i, 1, X) {
        if(A[i]) {
            ans++;
        }
    }
    int tmp = 0;
    FOR(i, X + 1, N) {
        if(A[i]) {
            tmp++;
        }
    }
    ans = min(ans, tmp);
    cout << ans << "\n";
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var s = LnStr();
        if (s[2] == s[3] && s[4] == s[5])
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
   

public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define isz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()

using vi = std::vector<int>;
using ll = long long;

ll solve(vi d, const int n, const int x, const int m) {
    for (auto &it : d) it %= m;
    if (isz(d) > n) d.resize(n);
    int nZeros = 0;
    for (auto &it : d) nZeros += (it == 0);
    ll s = std::accumulate(all(d), 0LL);
    int last = n-2;
    int q = last / isz(d);
    int r = last % isz(d);
    ll y = x + q * s;
    nZeros *= q;
    for (int i = 0; i <= r; i++) y += d[i], nZeros += (d[i] == 0);
    ll nLess = y / m;
    return n-1 - nLess - nZeros;
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    int k, q; std::cin >> k >> q;
    vi d(k);
    for (auto &it : d) std::cin >> it;
    while (q--) {
        int n, x, m; std::cin >> n >> x >> m;
        std::cout << solve(d,n,x%m,m) << "\n";
    }
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  bool ans = true;
  
  rep(i, n){
    if(s.at(i) != s.at(n-1-i))
      ans = false;
  }
//  cout << ans << endl;
  rep(i, (n-1)/2){
    if(s.at(i) != s.at((n-1)/2 -1-i))
      ans = false;
  }
//  cout << ans << endl;
  for(ll i=(n+3)/2; i<n; i++){ 
    if(s.at(i) != s.at(n-1-i))
      ans = false;
  }
  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main(){
  int *array, i, j, n1, n2, key, count = 0;
  
  scanf("%d",&n1);
  array = malloc((n1 + 1) * sizeof(int));
  
  for(i = 0; i < n1; i++){
    scanf("%d",&array[i]); 
  }
  scanf("%d",&n2);
  for(i = 0; i < n2; i++){
    scanf("%d",&key);
    array[n1] = key;
    j = 0;
    while(array[j] != key){
      j++;
    }
    if(j == n1){
	
    }
    else{
      count++;
    }
  }
  printf("%d\n",count);
  
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
int accepted[1000000];
int unaccepted[1000000];
int main()
{
    int n,a,pronum,ac_num=0,penalize=0;;
    string state;
    cin>>a>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>pronum;
        cin>>state;
        if(state=="WA" && accepted[pronum]==0)unaccepted[pronum]+=1;
        if(state=="AC" && accepted[pronum]==0)accepted[pronum]=1;
    }
    for(int i=1;i<=a;i++)
    	if(unaccepted[i]>=1 && accepted[i]==1)penalize+=unaccepted[i];
    for(int i=1;i<=a;i++)
    {
        if(accepted[i]==1)ac_num++;
    }
    cout<<ac_num<<' '<<penalize<<'\n';
    return 0;
}

Measured memory_bytes: 4736
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=0;i<b;i++)
#define REP(i,a,b) for(int i=0;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout <<(f?"Yes":"No")<<endl//fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout <<(f?"yes":"no")<<endl
#define YES(f) cout <<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())

using namespace std;

const int mod=1e9+7;

signed main(){
    int a,b,h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
}



Measured memory_bytes: 256
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.exception : enforce;

int n, p;
int[] a;

void main() {
    scan(n, p);
    a = readln.split.to!(int[]);

    if (a.all!"!(a & 1)") {
        writeln(p == 0 ? 1L<<n : 0);
        return;
    }
    else {
        writeln(1L<<(n - 1));
        return;
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A, B;
	cin >> A >> B;
	cout << max(max(A + B, A - B), A*B) << endl;

	return 0;
}

Measured memory_bytes: 256
def count(dic,x):
    if x in dic:
        dic[x]+=1
    else:
        dic[x]=1

N=int(input())
A=list(map(int,input().split()))
dic1={}
dic2={}
s=0
for i in range(N):
    count(dic1,i-A[i])
    count(dic2,i+A[i])
for x in dic1:
    if x in dic2:
        s+=dic1[x]*dic2[x]
print(s)



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

using namespace std;

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

	int h, w, k;
	cin >> h >> w >> k;
	
	vector<string> s;
	s.resize(h);

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

	int ans = h * w;

	for(int S = 0; S < 1 << (h - 1); ++S) {
		vector<int> sum;
		sum.resize(h);

		bool ok = true;

		int cnt = __builtin_popcount(S);

		for(int j = 0; j < w; ++j) {
			int p = 0;

			vector<int> tmp;
			tmp.resize(h);

			for(int i = 0; i < h; ++i) {
				tmp[p] += (s[i][j] == '1');

				if(S >> i & 1) {
					++p;
				}
			}		

			if(*max_element(tmp.begin(), tmp.end()) > k) {
				ok = false;
				break;
			}

			bool cut = false;

			for(int i = 0; i <= p; ++i) {
				if(sum[i] + tmp[i] > k) {
					cut = true;
					break;
				}
			}

			if(cut) {
				++cnt;

				for(int i = 0; i <= p; ++i) {
					sum[i] = tmp[i];
				}
			} else {
				for(int i = 0; i <= p; ++i) {
					sum[i] += tmp[i];
				}
			}
		}

		if(ok) {
			ans = min(ans, cnt);
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;


int main(void){
	
	int n;
	int a,b,c;
	cin>>n;
	while(n>0){
		cin>>a>>b>>c;
		if(a+b>c&&a+c>b&&b+c>a){
			
			if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a)
				cout<<"YES"<<endl;
			else{
				cout<<"NO"<<endl;
			}
			
		}
		else{
			cout<<"NO"<<endl;
		}
		
			
		n--;
	}
	
	
	return 0;
}


Measured memory_bytes: 3004
def solve(a,b):
    dp=[[0]*(len(b)+1) for _ in range(len(a)+1)]
    for i in range(len(a)+1):
        dp[i][0]=i
    for j in range(len(b)+1):
        dp[0][j]=j
    for i in range(1,len(a)+1):
        for j in range(1,len(b)+1):
            if a[i-1]==b[j-1]:
                dp[i][j]=min(dp[i-1][j-1],dp[i-1][j]+1,dp[i][j-1]+1)
            else:
                dp[i][j]=min(dp[i-1][j-1]+1,dp[i-1][j]+1,dp[i][j-1]+1)
    return dp[len(a)][len(b)]

a=input()
b=input()
print(solve(a,b))



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

inline int chaju(int a, int b) { return abs(a - (a + b) / 2); }

int main() {
    long long n, a, b;
    std ::cin >> n >> a >> b;
    if (a > b) std ::swap(a, b);
    if ((a + b) % 2 == 0) {
        long long ans = (b - a) / 2;
        std ::cout << ans << std ::endl;
    } else {
        long long ans1 = a + (b - a - 1) / 2;
        long long ans2 = n - b + 1 + (n - (a + n + 1 - b)) / 2;
        long long res = std ::min(b - 1, n - a);
        // std ::cout << ans1 << ' ' << ans2 << std ::endl;
        std ::cout << std ::min(ans1, std ::min(ans2, res)) << std::endl;
    }
    return 0;
}


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

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

	if (A == 5 && B == 5 && C == 7)
		cout << "YES" << endl;
	else if (A == 5 && B == 7 && C == 5)
		cout << "YES" << endl;
	else if (A == 7 && B == 5 && C == 5)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}


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

vector<bool> is_prime_list;
vector<long long int> Eratosthenes_Sieve(int n){// list of primes smaller than n
    is_prime_list.resize(n+1, true);
    is_prime_list[0] = false; 
    is_prime_list[1] = false;

    vector<long long int> primes;
    for (int i=2; i<=n; i++) {
        if (is_prime_list[i] == true){
            primes.push_back(i);
            for (int j=i*2; j<=n; j+=i){
                is_prime_list[j] = false;// exclude multipliers of i (prime)
            }
        }// if not prime, do nothing -> proceed to i+1
    }
    return primes;
}

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

    vector<int> a(n+1);
    for(int i=0; i<n+1; i++){
        cin >> a[i];
    }
    reverse(a.begin(),a.end());

    // list up candidates
    vector<long long int> prime_factor = Eratosthenes_Sieve(n);

    int m = abs(a[n]);
    for (int p=2; p*p<=m; p++) {
        if(m % p != 0) continue;

        while(m % p == 0) m /= p;
        if(p >= n) prime_factor.push_back(p);
    }
    if(m != 1 && m >= n) prime_factor.push_back(m);

    // verify each
    for(long long int pf : prime_factor){
        if(a[0] % pf != 0) continue;

        bool flag = true;
        if(n <= pf - 1){
            for(int i=1; i<=n; i++){
                if(a[i] % pf != 0) flag = false;
            }
        }
        else{
            vector<long long int> coeff(pf-1);
            for(int i=1; i<=n; i++){
                coeff[i%(pf-1)] += a[i];
                coeff[i%(pf-1)] = (coeff[i%(pf-1)] % pf + pf) % pf;
            }
            for(int i=0; i<pf-1; i++){
                if(coeff[i] % pf != 0) flag = false;
            }
        }

        if(flag == false) continue;
        cout << pf << endl;
    }
    return 0;
}

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

using namespace std;

void solve(string S) {
  cout << (S == "ABC" ? "ARC" : "ABC") << endl;
    
}

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

  string S;
  cin >> S;

  solve(S);

  return 0;
}


Measured memory_bytes: 3656
import sys
from itertools import combinations


def main():
    input = sys.stdin.buffer.readline
    while True:
        n, x = map(int, input().split())
        if n == x == 0:
            break
        ans = 0
        for c in combinations(range(1, n + 1), 3):
            ans += sum(c) == x
        print(ans)


if __name__ == "__main__":
    main()



Measured memory_bytes: 5612
import java.util.*;

public class Main {
    public static int MOD = 998244353;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int x = sc.nextInt();
        int m = sc.nextInt();
        
        TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
        List<Integer> list = new ArrayList<Integer>();
        list.add(x);
        map.put(x, 1);
        long now = x;
        int count = 1;
        int last = 0;
        for (long i = 0; i < n; i++) {
            now = (now * now) % m;
            int key = (int)now;
            
            int val = map.getOrDefault(key, 0);
            if (val == 1) {
                last = key;
                break;
            } else {
                map.put(key, ++val);
                count++;
                list.add(key);
            }
        }
        
        int last_idx = 0;
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i) == last) {
                last_idx = i;
            }
        }
        // System.out.println(last);
        // System.out.println(last_idx);
        
        int prev = last_idx;
        long block = (n-prev) / (count-prev);
        long amari = (n-prev) % (count-prev);
        
        List<Integer> list2 = new ArrayList<Integer>();
        long setsum = 0;
        for(int i = last_idx; i < count; i++) {
            list2.add(list.get(i));
            setsum += list.get(i);
        }
        
        // long block = n / count;
        // long amari = n % count;
        // long ans = 
        long ans = 0;
        for (int i = 0; i < last_idx; i++) {
            ans += list.get(i);
        }
        // System.out.println(ans);
        ans += block * setsum;
        // System.out.println(amari);
        for (Integer key : list2) {
            if (amari > 0) {
                ans += key;
                amari--;
            } else {
                break;
            }
        }
        // System.out.println(sum);
        // System.out.println(256+471+620+16+256+471+620);
        // System.out.println(count);
        // System.out.println(map.toString());
        // System.out.println(list.toString());
        System.out.println(ans);
    }
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define mod 1e9 +7;

typedef long long ll;
typedef vector<ll> vll;

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

string to_bin_string(ll n){
    stringstream ss;
    ss << bitset<8>(n); //任意の桁数<m>
    string s = ss.str();
    return s;
}
map<ll, ll> mp;
int main()
{
    ll n, sum = 0; 
    cin >> n;
    vll a(n);
    vector<pair<ll, ll> > p;
    rep(i,n){
        ll k;
        cin >> k;
        sum += k;
        a[i] = sum;
    }
    sort(all(a));

    ll cnt = 1, ans = 0;
    REP(i,1,n){
        if(a[i] == a[i-1])cnt++;
        else {
            p.push_back(make_pair(a[i-1], cnt));
            cnt = 1;
        }
    }
    p.push_back(make_pair(a[n-1], cnt));

    rep(i, p.size()){
        ll tmp = p[i].second;
        if(p[i].first == 0)ans += tmp;
        ans += tmp * (tmp - 1) / 2;
    }
    cout << ans << endl;

    return 0;
} 

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

int main(){
  int A,B;
  cin>>A>>B;
  if(A==1||B==1){
    if(A==1&&B!=1){
      cout<<"Alice"<<endl;
    }else if(A!=1&&B==1){
      cout<<"Bob"<<endl;
    }else{
      cout<<"Draw"<<endl;
    }
  }else{
    if(A==B){
      cout<<"Draw"<<endl;
    }else{
      cout<<(A<B?"Bob":"Alice")<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
def maxp(rs):
    maxv = rs[1] - rs[0]
    minv = rs[0]

    for j in range(1, len(rs)):
        if rs[j] - minv > maxv:
            maxv = rs[j] - minv
        if rs[j] < minv:
            minv = rs[j]

    return maxv

if __name__ == '__main__':

    n = int(input())
    rs = []
    for _ in range(n):
        rs.append(int(input()))

    print(maxp(rs))



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

int main(){
  long long n,k,dif;
  cin >> n >> k;
  if(n%k==0) cout << 0 << endl;
  else{
    dif=n%k;
    if(dif<=k-dif) cout << dif << endl;
    else cout << k-dif << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

H.append(10**10) 
r, ans = 0, 0
for l in range(N):
    while r < N and H[r] >= H[r+1]:
        r += 1
    ans = max(ans, r-l)
    if l == r:
        r += 1
print(ans)

Measured memory_bytes: 20480
#include<iostream>

using namespace std;

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

    tmp=a+b;
    k=(a+b)/2;
    if(tmp==k*2){
        cout<<k<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;

int solve(ll n) {
    set<ll> s;
    for (ll t = 1; t * t < n; ++t) 
    if ((n - 1) % t == 0) {
        if (t > 1) s.insert(t);
        if ((n - 1) / t > 1) s.insert((n - 1) / t);
    }

    for (ll t = 1; t * t <= n; ++t) 
    if (n % t == 0) {
        ll v = n;
        while (t > 1 && v % t == 0) v /= t;
        if (v % t == 1) s.insert(t);
        v = n;
        ll d = n / t;
        while (d > 1 && v % d == 0) v /= d;
        if (v % d == 1) s.insert(d);
    }
    return s.size();
}

int brute(ll n) {
    int ans = 0;
    for (ll t = 2; t <= n; ++t) {
        ll v = n;
        while (v % t == 0) v /= t;
        if (v % t == 1) ++ans;
    }
    return ans;
}

int main() {
    ll n;
    cin >> n;
    cout << solve(n) << endl;
}

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

const int64_t MOD= 1000000007;
/* 剰余環 Z/nZ */
struct mint{ // Z/nZ に関する演算(n:素数の場合は除算も)をサポートする構造体
  int64_t rep; // 出力すべき代表元 rep \in {0,1,..,MOD- 1}
  mint(int64_t x=0): rep(((x%MOD)+ MOD)% MOD){}
  mint operator-() const { return mint(-rep);}
  mint& operator+=(const mint& x){
    rep+= x.rep; 
    if(rep>= MOD) rep-= MOD;
    return *this;
  }
  mint& operator-=(const mint& x){
    rep-= x.rep;
    if(rep< 0) rep+= MOD;
    return *this;
  }
  mint& operator*=(const mint& x){
    rep*= x.rep; rep%= MOD;
    return *this;
  }
  mint operator+(const mint x) const {
    mint ans(*this);
    ans+= x;
    return ans;
  }
  mint operator-(const mint x) const {
    mint ans(*this);
    ans-= x;
    return ans;
  }
  mint operator*(const mint x) const {
    mint ans(*this);
    ans*= x;
    return ans;
  }

  mint pow(int64_t d) const{ // d \geq 0
    if(d==0) return 1;
    else{
      mint ans= pow(d>>1);
      ans*= ans;
      if(d&1){ ans*= *this; }

      return ans;
    }
  }

  friend istream& operator >> (istream &is, mint& x) noexcept{
    int64_t a;
    is >> a;
    x= a;
    return is;
  }
  friend ostream& operator << (ostream &os, const mint& x) noexcept{
      return os << x.rep;
  }
  // MOD が素数(<=> Z/nZ が体)のとき
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint& x){
    *this *= x.inv();
    return *this;
  }
  mint operator/(const mint x) const {
    mint ans(*this);
    ans/= x;
    return ans;
  }
};
// ^^^ テンプレここまで ^^^


// \sum_i \sum_j a_i b_j= (\sum_i a_i) (\sum_j b_j) 
// によって2次元和を1次元ずつに分ける。
// この問題の場合、
// a_i= (i+1)*(Nx-i-1)* (data_x.at(i+1)- data_x.at(i))
// b_j= (j+1)*(Ny-j-1)* (data_y.at(j+1)- data_y.at(j))
int main(){
  int64_t Nx,Ny;
  cin >> Nx >> Ny;

  vector<int64_t> data_x(Nx);
  vector<int64_t> data_y(Ny);
  for(auto i=0; i<Nx; i++){
    cin >> data_x.at(i);
  }
  for(auto j=0; j<Ny; j++){
    cin >> data_y.at(j);
  }

  mint sum_x= 0;
  mint sum_y= 0;
  for(int64_t i=0; i+1 < Nx; i++){
    sum_x+= (i+1)*(Nx-i-1)* (data_x.at(i+1)- data_x.at(i));
  }
  for(int64_t j=0; j+1 < Ny; j++){
    sum_y+= (j+1)*(Ny-j-1)* (data_y.at(j+1)- data_y.at(j)); 
  }

  mint ans= sum_x* sum_y;

  cout << ans << endl;
}

Measured memory_bytes: 4812
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  p=list(map(int,input().split()))
  p.sort()
  ans=0
  on=1
  dif=1
  if x in p:
    now=p.index(x)
    while on==1:
      if now-dif<0:
        ans=x-dif
        on=0
      elif p[now-dif]!=x-dif:
        ans=x-dif
        on=0
      elif now+dif==n:
        ans=x+dif  
        on=0
      elif p[now+dif]!=x+dif:
        ans=x+dif
        on=0
      else:
        dif+=1
    print(ans)
  else:
    print(x)

Measured memory_bytes: 9208