akhauriyash/Code-Regression huggingface dataset:
/************************************/
/* NoobM							*/
/* File Name : atjp.cpp				*/
/* Date : 05.07.2020 18:00:02 +06	*/
/************************************/

#include <bits/stdc++.h>

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

void solve() {
	int n;
	cin >> n;
	
	if(n % 1000 != 0)cout << 1000 - n%1000 << endl;
	else cout << 0 << endl;
	
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
	
	int t = 1;
	//cin >> t;
	
	while (t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define sz 200002
#define pb push_back
#define ff first
#define ln '\n'
#define ss second
#define ll long long
#define VEC vector<ll int>v
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}



int main()
{
    ll int n,m,res=100000025,a,b;

    cin>>n;
   VEC;
   for(int i=0;i<n;i++)
   {
       cin>>a;
       v.pb(a);
   }
   for(int i=0;i<=100;i++)
   {   a=0;
       for(int j=0;j<n;j++)
       {
           a+=(i-v[j])*(i-v[j]);
       }
       res=min(res,a);
   }
    cout<<res<<endl;

    return 0;
}


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

main(){
    string s;
    cin >> s;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]==s[i+1]){
            puts("Bad");
            exit(0);
        }
    }
    puts("Good");

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	private static final long MOD = (long)Math.pow(10, 9) + 7l;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		String s = sc.next();
		int res = 0;
		int sum = 0;
		for (int i = 0 ; i < n; i++) {
			char c = s.charAt(i);
			if (c == 'I') {
				sum++;
			} else {
				sum--;
			}
			res = Math.max(res, sum);
		}
		System.out.println(res);
	}
  
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      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 nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 21844
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define lint long long

using namespace std;

int main()
{
  string s;
  cin >> s;
  
  if(s=="Rainy"){
    cout << "Sunny" << endl;
  }else if(s=="Sunny"){
    cout << "Cloudy" << endl;
  }else{
    cout << "Rainy" << endl;
  }
  return 0;
}

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

using A=vector<pair<long long,long long>>;

A prime_factorize(long long N){
  A res;
  for(long long i=2;i*i<=N;i++){
    if(N%i!=0){
      continue;
    }
    long long ex=0;
    while(N%i==0){
      ex++;
      N/=i;
    }
    res.push_back(make_pair(i,ex));
  }
  if(N!=1){
    res.push_back(make_pair(N,1));
  }
  return res;
}
    
int main(){
  long long N,count=0;
  cin >> N;
  A res=prime_factorize(N);
  for(int i=0;i<res.size();i++){
    long long B=res.at(i).second;
    int j=1;
    while(B-j>=0){
      count++;
      B-=j;
      j++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3608
/*input
1 1000
*/
#include<bits/stdc++.h>
#define ll long long int
#define nl "\n"
using namespace std;


int main()
{
  int h,a;
  cin>>h>>a;
  int ans=0;
  if(h%a!=0)
  	ans = (h/a)+1;
  else
  	ans = h/a;
  cout<<ans;

return 0;
}
	

Measured memory_bytes: 256
n = int(input())

cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]

for i in range(n):
    ch, rank = map(str, input().split())
    cards[pattern.index(ch)][int(rank) - 1] = True

for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j + 1)


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n, k;
  cin >> n >> k;
  vl a(n);
  rep(i, n) cin >> a[i];
  for (int i = k + 1; i <= n; i++) {
    if (a[i - k - 1] < a[i - 1]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 4780
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;

	return gcd(b, a%b);
}

int main()
{
	ll n,ans=0;
	string s;

	cin >> n;

	forll(i, 0, n)
	{
		forll(j, 0, n)
		{
			ll buf = gcd(max(i+1,j+1), min(i + 1,j + 1));

			forll(k, 0, n)
			{
				ans += gcd(max(buf, k + 1), min(buf, k + 1));
			}
		}
	}


	cout << ans << endl;

}

Measured memory_bytes: 3624
S = gets.chomp
T = gets.chomp
idx = {}
(0...S.size).each{ |i|
  idx[S[i]] ||= []
  idx[S[i]] << i
}
idx.values.each{ |xs| xs << xs[0] + S.size }
ans = 0
j = 0
T.chars.each{ |c|
  xs = idx[c]
  if !xs
    p -1; exit
  end
  k = xs.bsearch{ |k| k >= j }
  #$stderr.puts "#{c} #{j} #{k}"
  ans += k - j + 1
  j = (k+1) % S.size
}
p ans


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

int main()
{
  vector<int> a(3);
  rep(i, 3) cin >> a.at(i);
  sort(a.begin(), a.end());

  // rep(i, 3) cout << a.at(i);

  cout << a.at(0) + a.at(1);

  // cout << tmp;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int H, W;
    cin >> H >> W;
    string S[H];
    REP(i, H) cin >> S[i];

    int hor[H * W];
    int ver[H * W];
    REP(i, H) {
        bool f = false;
        int c = 0;
        int begin = 0;
        REP(j, W) {
            if (S[i][j] == '#') {
                if (f) {
                    for (int k = begin; k < j; ++k) hor[i * W + k] = c;
                }
                hor[i * W + j] = 0;
                f = false;
                c = 0;
            }
            else {
                if (!f) begin = j;
                f = true;
                c++;
            }
        }
        if (f) {
            for (int k = begin; k < W; ++k) hor[i * W + k] = c;
        }
    }
    REP(j, W) {
        bool f = false;
        int c = 0;
        int begin = 0;
        REP(i, H) {
            if (S[i][j] == '#') {
                if (f) {
                    for (int k = begin; k < i; ++k) ver[k * W + j] = c;
                }
                ver[i * W + j] = 0;
                f = false;
                c = 0;
            }
            else {
                if (!f) begin = i;
                f = true;
                c++;
            }
        }
        if (f) {
            for (int k = begin; k < H; ++k) ver[k * W + j] = c;
        }
    }
    int m = 0;
    REP(i, H) {
        REP(j, W) {
            int c = hor[i * W + j] + ver[i * W + j] - 1;
            if (c > m) m = c;
        }
    }
    cout << m << endl;


    return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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(){
  ll n;
  cin >> n;
  vi l(n);
  ll sum=0;
  rep(i, n){
    cin >> l[i];
    sum += l[i];
  }
  sort(all(l));
  sum -= l[n-1];
  if(l[n-1]<sum){
    print("Yes");
  }
  else{
    print("No");
  }
}

Measured memory_bytes: 256
import sys
# import math
input = sys.stdin.readline


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


def str_array():
    return input().strip().split()

######################### TEMPLATE ENDS HERE ##################################

n = input().strip()
uppercase = [chr(i) for i in range(65, 65+26)]
lowercase = [chr(i) for i in range(97, 97+26)]
if n in uppercase:
    print("A")
else:
    print("a")


Measured memory_bytes: 61736
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S; cin >> S; 
	for(int i = 0; i < 3; i++){
		if(S.at(i) == '7'){
			cout << "Yes" << endl; return 0;
		} 
	}
	cout << "No" << endl; 
}

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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
	int n;
	cin >>n;
	int wari = n/15 * 200;
	cout<<800*n - wari<<endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion

ll max_sum(const vector<vector<pair<ll, ll>>> &v) {
    ll sum = 0;
    rep(i, v.size()) for (auto p: v[i]) sum += p.second;

    priority_queue<ll, vector<ll>, greater<ll>> que;
    vector<vector<ll>> d(v.size());
    rep(i, v.size()) for (auto p: v[i]) d[i].push_back(p.first - p.second);
    repr(i, 1, d.size()) {
        for (ll x: d[i]) que.push(x);
        while(i < que.size()) que.pop();
    }
    while (!que.empty()) {
        sum += que.top(); que.pop();
    }
    return sum;
}

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

    rep(_, t) {
        int n;
        cin >> n;
        vector<vector<pair<ll, ll>>> g1(n + 1), g2(n + 1);
        rep(i, n) {
            int k, l, r;
            cin >> k >> l >> r;
            if (l >= r) g1[k].push_back({l, r});
            else g2[n - k].push_back({r, l});
        }

        ll ans = max_sum(g1) + max_sum(g2);
        cout << ans << endl;
    }
}

Measured memory_bytes: 26788
#include<stdio.h>
#define it register int
#define P 1000000007
int ans,n,inv[1000005];
int main(){
    scanf("%d",&n);it i,mx=n<3?3:n;
    inv[0]=inv[1]=1;for(i=2;i<=mx;++i) inv[i]=(0ll+inv[P%i])*(P-P/i)%P;
    it pw=inv[3];
    for(i=1;i<=n;++i) ans=(ans+(0ll+pw)*inv[n]%P*inv[n-i+1])%P,pw=(0ll+pw)*inv[3]%P;
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll f(ll b, ll n) {
  ll res = 0, k = n;
  do {
    res += k % b;
    k /= b;
  } while (k);
  return res;
}

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

  if (n == s) {
    cout << n + 1 << endl;
    return 0;
  }

  for (ll b = 2; b <= sqrt(n); ++b) {
    if (f(b, n) == s) {
      cout << b << endl;
      return 0;
    }
  }

  const ll INF = 1e18;
  ll ans = INF;
  for (ll p = 1; p < sqrt(n); ++p) {
    ll b = (n - s) / p + 1;
    if (b > 1 && f(b, n) == s) chmin(ans, b);
  }

  cout << (ans == INF ? -1 : ans) << endl;

  return 0;
}


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

Measured memory_bytes: 592
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] strArray = br.readLine().split(" ");
        
        //int[] price = new int[3];
        
        int sum = 0;
        int maxPrice = 0;
        for(int i = 0; i < 3; i++){
            int tmp = Integer.parseInt(strArray[i]);
            sum += tmp;
            
            if(tmp > maxPrice){
                maxPrice = tmp;
            }
        }
        
        System.out.println(sum - maxPrice);
    }
}


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

using namespace std;
using ll = long long;
using ld = long double;

namespace NyaGadgetCpp17
{
	/**
	@brief 最大公約数を計算する関数
	@note
	 aとbの最大公約数を返す
	**/
	long long Gcd(long long a, long long b)
	{
		return b ? Gcd(b, a % b) : a;
	}
	/**
	@brief 最小公倍数を計算する関数
	@note
	 aとbの最小公倍数を返す
	**/
	long long Lcm(long long a, long long b)
	{
		return a / Gcd(a, b) * b;
	}
};

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define ceil(a, b) ceil((ld) a / (ld) b);                         // div ceiling
#define each(e, collection) for(auto& e: collection)              // for each
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

using namespace NyaGadgetCpp17;

int main(void)
{
	ll n; cin >> n;
	vector<ll> d(n);
	each(e, d)
		cin >> e;

	ll ans = 0;
	rep(i, 0, n)
	{
		rep(j, 0, i)
		{
			ans += d[i]* d[j];
		}
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          N (int)2e5+5
#define          pb push_back
#define          mod 1000000007
#define          ld long double
#define          vi vector<int>
#define          eb emplace_back
#define          vpii vector<pii>
#define          mii map<int,int>
#define          int long long 
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          PI acos(-1.0)
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q,c;
string s;
vi adj[N];
int vis[N],par[N],a[N];

void go()
{
	cin >> n >> k >> c;
	cin >> s;

	vi left(k) , right(k);

	int j = 0;

	fo(i,0,k)
	{
		while( s[j] == 'x' ) j++;

		left[i] = j;
		j += c + 1;
	}

	j = n - 1;

	rfo(i,k-1,0)
	{
		while( j >= 0 and s[j] == 'x' ) j--;
		right[i] = j;
		j -=( c + 1);
	}


	fo(i,0,k)
	{
		if( left[i] == right[i] ) cout << left[i] + 1 << endl;
	}
}

int32_t main()
{
	//INP(); 
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}

 

Measured memory_bytes: 10260
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


/* define */
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define REP(i, n) for ( int i = 0; i < (n) ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1000000007;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	c -= a - b;
	cout << max(c, 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll p=pow(10,9)+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      
    x = x % p;  
   while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 

ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,j,i,k,m1,y1,m2,y2;
    cin>>n;
    ll arr[n],flag=1;
    for(i=0;i<n;i++)
    cin>>arr[i];
    map<ll,ll> m;
    for(i=0;i<n;i++)
    {
        if(m[arr[i]]==0)
        m[arr[i]]++;
        else
        {
            flag=0;
            cout<<"NO";
            break;
        }
    }
    if(flag==1)
    cout<<"YES";


    return 0;
    
}
    


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

int count(ll d){
	int res = 0;
	while(d){
		++res;	
		d/=10;
	}
	return res;
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	ll n;
	cin >> n;
	const int inf = 1e9;
	int ans = inf;
	for(ll i = 1;i * i <= n; ++i){
		if(n % i == 0){
			gmin(ans, max(count(i),count(n/i)));
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const lint INF = 1LL << 60;

int main() {
    lint h, w;
    cin >> h >> w;

    if (h % 3 == 0 || w % 3 == 0) {
        cout << 0 << endl;
        exit(0);
    }

    lint res = INF;

    for (int x = 1; x < w; x++) {
        lint a = h * x;
        lint half = h/2;
        lint b = half * (w-x);
        lint c = (h - half) * (w-x);

        lint mi = min({a, b, c});
        lint mx = max({a, b, c});
        res = min(res, mx - mi);
    }

    for (int x = 1; x < h; x++) {
        lint a = w * x;
        lint half = w/2;
        lint b = half * (h-x);
        lint c = (w - half) * (h-x);

        lint mi = min({a, b, c});
        lint mx = max({a, b, c});
        res = min(res, mx - mi);
    }

    res = min(res, h);
    res = min(res, w);

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

int main(void)
{
    int n; cin >> n;
    vector<int> cnt(100000, 0);
    long long sum = 0;
    int a;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        sum += a;
        cnt[a-1]++;
    }
    int q; cin >> q;
    int b, c;
    vector<long long> ans(q, 0);
    for (int i = 0; i < q; i++)
    {
        cin >> b >> c;
        sum = sum + (c - b) * cnt[b-1];
        cnt[c-1] += cnt[b-1];
        cnt[b-1] = 0;
        ans[i] = sum;
    }
    for (int i = 0; i < q; i++)
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 4576
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) {
		try (BufferedReader stdReader = new BufferedReader(
				new InputStreamReader(System.in))) {
			String line = null;
			while ((line = stdReader.readLine()) != null) {
				if (!line.equals("")) {
					String[] lineArray = line.split(" ");
					int tate = Integer.parseInt(lineArray[0]);
					int yoko = Integer.parseInt(lineArray[1]);
					System.out.print(tate * yoko);
					System.out.print(" " + ((tate * 2) + (yoko * 2)));
				}
				break;
			}
			System.out.println();
		} catch (Exception e) {

		}
	}
}

Measured memory_bytes: 24256
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline

ans = 0
N, M, Q = map(int, rl().split())
abcd = [list(map(int, rl().split())) for _ in range(Q)]


def calc(A):
    if len(A) == N:
        tmp = 0
        for a, b, c, d in abcd:
            if A[b - 1] - A[a - 1] == c:
                tmp += d
        global ans
        ans = max(ans, tmp)
    else:
        for i in range(A[-1], M + 1):
            calc(A + [i])


def solve():
    for i in range(1, M + 1):
        calc([i])
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 71372
#include <stdio.h>
#include <iostream>


using namespace std;
void call(int n){
	int i=1;
	do{
		int x=i;
		if(x%3==0){
			cout<<" "<<i;
		}else{
			do
			{
				if(x%10==3){
					cout<<" "<<i;	
					break;
				}
				x/=10;
			}while(x);
		}
	}while(++i<=n); 
	cout << endl;
 }
 	

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



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

public class Main {

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

		int add = A + B;
		int sub = A - B;
		int mul = A * B;

		//add,sub,mulのうちで最大のものを求める
		int array[] = {add, sub, mul};
		Arrays.sort(array);

		//System.out.println(array[0]);
		//System.out.println(array[1]);
		System.out.println(array[2]);
	}
}


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

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            long ans = 0;
            for (int i = 1; i <= n; i++)
            {
                var a = i;
                var d = i;
                var nn = n / i;
                ans += nn * (2 * a + (nn - 1) * d) / 2;
            }

            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27248
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K,x,s=0,a,b;
  cin >> N >> K;
  for (int i=0;i<N;i++){
    cin >> x;
    a = 2 * x;
    if (x >= K){
      b = (x - K) * 2;
    }else{
      b = (K - x) * 2;
    }
    if (a <= b){
      s += a;
    }else{
      s += b;
    }
  }
  cout << s << endl;
}


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

int get_sum_of_digits(int n) {
    int sum = 0;
    while(n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int sums(int n, int a, int b){
    int total = 0;
    for (int i=1; i<=n; i++) {
        int sum = get_sum_of_digits(i);
        if (sum >= a && sum <= b) {
            total += i;
        }
    }
    return total;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << sums(n, a, b) << endl;
}



Measured memory_bytes: 256
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <LL,LL>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,n2=1,m,lb[200010],ub[200010],a[200010],dat[800010],add[800010],dp[200010],ans=0;
vector <LL> v[2][200010];

void upd(LL k,LL lb,LL ub,LL tlb,LL tub,LL val)
{
  if(ub<tlb||tub<lb) return;
  if(tlb<=lb&&ub<=tub)
  {
    add[k]+=val;
    return;
  }
  upd(k*2+1,lb,(lb+ub)/2,tlb,tub,val);
  upd(k*2+2,(lb+ub)/2+1,ub,tlb,tub,val);
  dat[k]=max(dat[k*2+1]+add[k*2+1],dat[k*2+2]+add[k*2+2]);
}

void upd2(LL k,LL val)
{
  dat[k]=val;
  while(k>0)
  {
    k=(k-1)/2;
    dat[k]=max(dat[k*2+1]+add[k*2+1],dat[k*2+2]+add[k*2+2]);
  }
}

LL query(LL k,LL lb,LL ub,LL tlb,LL tub)
{
  if(ub<tlb||tub<lb) return -1e18;
  if(tlb<=lb&&ub<=tub) return dat[k]+add[k];
  return max(query(k*2+1,lb,(lb+ub)/2,tlb,tub),query(k*2+2,(lb+ub)/2+1,ub,tlb,tub))+add[k];
}

int main()
{
  cin>>n>>m;
  while(n2<n) n2*=2;
  rep(i,m)
  {
    scanf("%lld%lld%lld",&lb[i],&ub[i],&a[i]);
    v[0][lb[i]].pb(i);
    v[1][ub[i]].pb(i);
  }
  repn(i,n2-1) upd2(i+n2-1,-1e18);
  repn(i,n)
  {
    rep(j,v[0][i].size()) upd(0,0,n2-1,0,i-1,a[v[0][i][j]]);
    dp[i]=query(0,0,n2-1,0,i-1);
    ans=max(ans,dp[i]);
    upd2(i+n2-1,dp[i]);
    rep(j,v[1][i].size()) upd(0,0,n2-1,0,lb[v[1][i][j]]-1,-a[v[1][i][j]]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 40832
#include <bits/stdc++.h>
#define int LL
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
string str;
void cul(int m,int Base)
{
	int temp;
	while(m)
	{
		temp=m%Base;
		m=m/Base;
		if(temp<0)
		{
			temp-=Base;
			m+=1;
		}
		if(temp>9)
			str=char(temp-10+'A')+str;
        else
			str=char(temp+'0')+str;
	}
}
signed main()
{
	cul(read(),-2);
	cout<<(str.empty()?"0":str)<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,x,i;cin>>n;
    vector<int>v;
  	for(i=1;i<=n;i++){
    	cin>>x;
    	if(x>i) {cout<<-1<<endl;return 0;}
    	v.insert(v.begin()+x-1,x);
  	}
  	for(auto it:v)cout<<it<<endl;
    return 0;
}


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

using namespace std;

int main(void)
{
        string a, b;

        cin >> a;
        cin >> b;

        if( a.size() > b.size() )
                cout << "GREATER" << endl;
        else if( a.size() < b.size() )
                cout << "LESS" << endl;
        else
        {
                if( a > b )
                        cout << "GREATER" << endl;
                else if( a < b )
                        cout << "LESS" << endl;
                else
                        cout << "EQUAL" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (ll x = a; x <= b; ++x)
#define for1(x, a, b) for (ll x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

ll n, A, B, C, D;

bool in(ll x, ll l, ll r) {
    return (l <= x && x <= r);
}

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

	cin >> n >> A >> B >> C >> D;
	forn(i, 1, n) {
        ll l1 = A + C * (i - 1), r1 = A + D * (i - 1);
        ll l2 = B + C * (n - i - 1), r2 = B + D * (n - i - 1);
        if (in(l2 + D, l1, r1) || in(l2 + C, l1, r1) || in(r2 - C, l1, r1) || in(r2 + C, l1, r1) || in(r1 - C, l2, r2) || in(l1 - C, l2, r2) || in(l1 + C, l2, r2) || (l1 - C > r2 && l1 - D < l2) || in(r1 - D, l2, r2)) {
            cout << "YES\n";
//            cerr << l1 << " " << r1 << " " << l2 << " " << r2 << "\n";
            return 0;
        }
    }

    cout << "NO\n";

	return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
remain = A[0]
power = 0
ans = 0
for i in range(n):
    if remain < B[i]:
        power = B[i] - remain
        ans += remain
        if A[i + 1] > power:
            ans += power
            remain = A[i + 1] - power
        else:
            ans += A[i + 1]
            remain = 0
    else:
        power = 0
        ans += B[i]
        remain = A[i + 1]
print(ans)


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

using namespace std;

int main(){

  int w,h;
  int n;
  
  cin>>w>>h;
  cin>>n;

  vector<int> p(n);

  for(int i=0;i<n;++i)
	cin>>p[i];

  int in = 0;
  int out = 0;
  int cnt = 0;

  for(auto i:p){

	if(i == 1)
	  in++;
	else if(i == 0)
	  out++;

	if(out <= w-2 && out == in)
	  cnt++;
	
	else if(out >= w && out <= w+h-3 && out - in == 2)
	  cnt++;

	else if(out >= w+h-1 && out - in == 4)
	  cnt++;
	
  }

  cout<<cnt<<endl;

}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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 ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    const int lim = 62;
    vector<ll> cnt(lim);
    rep(i, n){
        for(int j=0; j<lim; j++){
            if((v[i] >> j) & 1) cnt[j]++;
        }
    }

    ll ans = 0;
    ll m = n;
    rep(i, n-1){
        m--;
        for(int j=0; j<lim; j++){
            if((v[i] >> j) & 1) cnt[j]--;
        }

        ll base = 1;
        for(int j=0; j<lim; j++){
            if((v[i] >> j) & 1){
                ans += (base * (m - cnt[j])) % MOD;
                ans %= MOD;
            }
            else {
                ans += (base * cnt[j]) % MOD;
                ans %= MOD;
            }
            base *= 2;
            base %= MOD;
        }
    }

    cout << ans%MOD << endl;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <algorithm>
using namespace std;
#define fr first
#define se second
#define pr pair<int,int>
#define mp make_pair
#define N 300000
int n,m,i,j,mask,a[N],l[20][N],r[20][N],k,f[N<<1],g[N<<1],id;
pr b[N<<1];
bool c[N];
int main()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);int psz=0,jj=-1;
	for (j=m;j!=jj;jj=j,j>>=1){
		int lst=1;
		for (i=2;i<=n;i++) if (a[i]-a[i-1]>j){
			for (k=lst;k<i;k++) l[psz][k]=lst,r[psz][k]=i-1;
			lst=i;
		}
		for (k=lst;k<=n;k++) l[psz][k]=lst,r[psz][k]=n;
		psz++;
	}
	for (mask=0;mask<(1<<psz);mask++)
	for (i=0;i<psz;i++) if (!(mask&(1<<i))) f[mask|(1<<i)]=max(f[mask|(1<<i)],r[i][f[mask]+1]);
	for (mask=0;mask<(1<<psz);mask++) g[mask]=n+1;
	for (mask=0;mask<(1<<psz);mask++)
	for (i=0;i<psz;i++) if (!(mask&(1<<i))) g[mask|(1<<i)]=min(g[mask|(1<<i)],l[i][g[mask]-1]);
	for (mask=0;mask<(1<<psz);mask++) if (!(mask&1)) b[++id]=mp(g[mask],mask);
	for (i=1;i<=n;i++) b[++id]=mp(r[0][i]+1,i+(1<<psz));
	sort(b+1,b+id+1);int wtf=-1;
	for (i=1;i<=id;i++) if (b[i].se>(1<<psz)){
		b[i].se-=(1<<psz);
		if (wtf>=l[0][b[i].se]-1) c[b[i].se]=true;
	}else wtf=max(wtf,f[b[i].se^((1<<psz)-2)]);
	for (i=1;i<=n;i++) if (c[i]) puts("Possible");else puts("Impossible");
	return 0;
}

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

int main(){
	int a;
	cin>>a;
	int d=0;
	for(int i=0;i<a;i++){
		int b[100000],c[100000];
		cin>>b[i]>>c[i];
		d+=c[i]-b[i]+1;
	}
	cout<<d<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long x,k,d,ans;
    cin>>x>>k>>d;
    
    x=abs(x);
    if(x/d > k){
        ans=x-k*d;
    }
    else{
        long long e = x/d;
        if((k-e)%2 == 1) ans=abs(x%d -d);
        else ans=abs(x%d);
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
# abc154_b.py
# https://atcoder.jp/contests/abc154/tasks/abc154_b

# B - I miss you... /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点: 200点

# 問題文
# 文字列 Sが与えられます。Sのすべての文字を x で置き換えて出力してください。

# 制約
#     Sは英小文字のみからなる文字列
#     Sの長さは 1 以上 100以下

# 入力
# 入力は以下の形式で標準入力から与えられる。
# S

# 出力
# Sのすべての文字を x で置き換えて出力せよ。

# 入力例 1
# sardine

# 出力例 1
# xxxxxxx

# sardine のすべての文字を x で置き換えると xxxxxxx となります。

# 入力例 2
# xxxx

# 出力例 2
# xxxx

# 入力例 3
# gone

# 出力例 3
# xxxx


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    S = lines[0]
    # N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = 'x' * len(S)

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['sardine']
        lines_export = ['xxxxxxx']
    if pattern == 2:
        lines_input = ['xxxx']
        lines_export = ['xxxx']
    if pattern == 3:
        lines_input = ['gone']
        lines_export = ['xxxx']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9032
#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++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main(){
  ll Q;
  cin >> Q;
  vector<ll> l(Q), r(Q);
  rep(i, Q){
    cin >> l.at(i) >> r.at(i);
  }
  Sieve S = {100001};
  vector<ll> like(100001, 0);
  rep2(i, 3, 100001){
    if(S.isPrime(i)){
      if(S.isPrime((i+1)/2)){
        like.at(i) = like.at(i-1)+1;
      }
      else{
        like.at(i) = like.at(i-1);
      }
    }
    else{
      like.at(i) = like.at(i-1);
    }
  }
  rep(i, Q){
    cout << like.at(r.at(i))-like.at(l.at(i)-1) << endl;
  }
}

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

int main()
{
  string S;
  cin >> S;
  int d[4] = {};
  for(int i = 0; i < (int)S.size(); i++)
    if(S[i] == 'N')
      d[0]++;
    else if(S[i] == 'W')
      d[1]++;
    else if(S[i] == 'S')
      d[2]++;
    else
      d[3]++;
  if(((d[0] == 0 && d[2] == 0) || (d[0] > 0 && d[2] > 0)) && ((d[1] == 0 && d[3] == 0) || (d[1] > 0 && d[3] > 0)))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x) cout<<#x<<" = "<<(x)<<endl;
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  int p,m=0,sum=0;
  REP(i,n) {
    cin >> p;
    sum+=p;
    m = max(p,m);
  }
  COUT(sum-m/2);
  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,L;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>L;
	int mi=101010;
	int S=0;
	FOR(i,N) {
		S+=L;
		if(abs(L)<abs(mi)) mi=L;
		mi=min(mi,abs(L));
		L++;
	}
	cout<<S-mi<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
N,L = map(int, input().split())
ringo = []
for i in range(1,N+1):
    ringo.append(L+i-1)
p = 200
p1 = 200
for i in ringo:
    p = abs(i)
    if p1 > p:
        p1 = p 
        ans = i
ringo.remove(ans)
print(sum(ringo))

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	int n,m,i,j,k,l,f,x,y;
	string a[55],b[55];
	cin >> n >> m;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	for(i=0;i<m;i++){
		cin >> b[i];
	}
	int flag=0;
	for(x=0;flag==0,x<=n-m;x++){
		for(y=0;flag==0,y<=n-m;y++){
			for(i=0;flag==0,i<m,i+x<n;i++){
				for(j=0;flag==0,j<m,j+y<n;j++){
					for(f=0,k=0;f==0,k<m;k++){
						for(l=0;f==0,l<m;l++){
							if(a[i+x+k][j+y+l]!=b[k][l]){
								f=1;
							}
						}
					}
					if(f==0){
						flag=1;
					}
				}
			}
		}
	}

	if(flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int n, t, b, cnt;

int main(){
	scanf("%d", &n);
	while(n--){
		scanf("%d", &t);
		if(t == b) cnt++, b = 0;
		else b = t;
	}
	
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n  = sc.nextInt
  val al = Vector.fill(n)(sc.nextInt)

  val cnt   = al.zipWithIndex.groupBy(_._1)
  

  val cnt2  = cnt.filter(_._2.size >= 2)
  val cnt4  = cnt2.filter(_._2.size >= 4)
  val over2 = cnt2.keySet.toVector
  val over4 = cnt4.keySet.toVector

  val bl = (over2 ++ over4).sortWith(_ > _)

  val res =
    if(bl.length <= 1) 0L
    else bl.head.toLong * bl.tail.head.toLong

  println(res)
}

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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i]=='A'||s[i]=='G'||s[i]=='C'||s[i]=='T')
        {
            cnt++;
        }
        else
        {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cnt = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256