akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REP_(i, a, b) for(int i = a; i <= b; i++)
#define sl(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define RepAll(a) for(auto x: a)
#define cout(ans) cout << ans << endl;
typedef long long ll;
ll a[10010];
using namespace std;
int main(){
    ll n;
    while(cin >> n){
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        ll cnt = 0;
            /*
            sort(a, a+n);
            if(a[n - 1] < n){
               cout << "0" << endl;
               continue;
            }
            else{
                for(int i = n-1; i >= 0&& a[i] >= n; i--){
                    cnt += (a[i] - n - 1)/n + 1;
                }
            */
    while(1){
        ll maxn = a[0], index = 0;

        for(int i = 0; i < n; i++){
           if(a[i] > maxn){
                maxn = a[i];
                index = i;
        }
        }
        if(maxn <= n-1) {
            break;
        }
        for(int i = 0; i <= n; i++){
            if(i == index)
            {
                a[i] = maxn%n; //最后剩下的数字
            }
            else
            {
                a[i] += maxn/n; //需要加的步数
            }
        }
        cnt += (maxn/n);
    }
    cout << cnt << endl;

    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++) cin >> d.at(i);
    sort(d.begin(), d.end());
    cout << d.at(N/2) - d.at(N/2-1) << endl;
}


Measured memory_bytes: 640
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
# mod = 998244353
# mod = 10 ** 9 + 9
mod = 10 ** 9 + 7
PI = Math::PI
dx = [ 1,  0, -1,  0,  1,  1, -1, -1]
dy = [ 0,  1,  0, -1,  1, -1,  1, -1]
eight = [0, 1, 1, 0, -1, -1, 1, -1, 0]
def max(a,b);       a > b ? a : b                              end
def min(a,b);       a < b ?  a : b                             end
def swap(a,b);      a, b = b, a                                end
def gi;             gets.to_s.to_i                             end
def gf;             gets.to_s.to_f                             end
def gs;             gets.to_s.chomp                            end
def gmi(n=nil); n.nil? ? gets.to_s.split.map{|t|t.to_i} : n.times.map{ gets.to_s.to_i } end
def gmf(n=nil); n.nil? ? gets.to_s.split.map{|t|t.to_f} : n.times.map{ gets.to_s.to_f } end
def gms(n=nil); n.nil? ? gets.to_s.split : n.times.map{ gets.to_s.chomp } end
def ga2i(h);        h.times.map{ gets.to_s.split.map{|t|t.to_i} }      end
def gm(h);        Array.new(h){ gets.to_s.split.map{|t|t.to_i} }      end
def yn(f); puts f ? "Yes" : "No" end
#def YN(f); puts f ? "YES" : "NO" end
def yes(f=nil); f.nil? ? (puts "Yes"; exit) : (puts f ? "Yes" : "No") end
def no(f=nil); f.nil? ? (puts "No"; exit) : (puts f ? "Yes" : "No") end
def yay(f=nil); f.nil? ? (puts "Yay!"; exit) : (puts f ? "Yay!" : ":(") end

#n = gets.to_s.to_i
# s = gets.to_s.chomp
# t = gets.to_s.chomp
n, m, x = gets.to_s.split.map{|e|e.to_i}
c = Array.new(n)
a = Array.new(n){ [] }
 
n.times do |i|
  c[i], *a[i] = gets.to_s.split.map{|e|e.to_i} 
end

ans = 10 ** 7
[0, 1].repeated_permutation(n) do |bit|
  
  cnt = 0
  # p bit
  rikaido = Array.new(m){ 0 }
  bit.each_with_index do |b, i|
    
    if b == 1
      
      cnt += c[i]
      
      m.times do |j|
        
        rikaido[j] += a[i][j]
        
      end
    end
  end
  
  ans = [ans, cnt].min if rikaido.all?{ |r| r >= x } 
end

puts ans == (10**7) ? -1 : ans

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

int main(){
    int a,b;
    int ans;
    char op = '+';

    while(1){
        cin>>a>>op>>b;
        if(op=='?')break;

        if(op=='+')ans = a+b;
        if(op=='-')ans = a-b;
        if(op=='*')ans = a*b;
        if(op=='/')ans = a/b;

        cout<<ans<<endl;
    }

    return 0;
}


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

int main(){
    int n,k;
    cin >> n >> k;
    int val = 1;
    rep(i,n){
        if(val+k > val*2){
            val = val*2;
        }
        else{
            val = val+k;
        }
    }


    cout << val << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
bool f[110];
int main(){
  ll n;
  cin>>n;
  P a[110],b[110];
  for(int i=0;i<n;i++)cin>>a[i].first>>a[i].second;
  for(int i=0;i<n;i++)cin>>b[i].first>>b[i].second;
  sort(a,a+n);
  sort(b,b+n);
  ll ans=0;
  for(int i=0;i<n;i++){
    P num,yan;
    num=make_pair(-1,-1);
    yan=num;
    for(int j=0;j<n;j++){
      if(f[j])continue;
      if(a[j].first<b[i].first&&a[j].second<b[i].second){
        if(num.second<a[j].second){
          num.second=a[j].second;
          num.first=j;
        }
      }
    }
    if(num!=yan){
      ans++;
      f[num.first]=1;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

  int D;
  cin>>D;
  
  int C[27];
  int S[366][27];
  vector<vector<int>> last(27);
  rep(i,27) last[i].push_back(0);

  for(int d=1;d<=26;d++) cin>>C[d];
  for(int d=1;d<=D;d++){
    for(int i=1;i<=26;i++) cin>>S[d][i];
  }

  for(int d=1;d<=D;d++){
    int mi=1;
    int max=-1e9;
    for(int i=1;i<=26;i++){
      int tmp=S[d][i];
      for(int j=1;j<=26;j++){
        if(j!=i) tmp-=C[j]*(d-last[j].back());
      }
      if(max<tmp){
        max=tmp;
        mi=i;
      }
    }
    last[mi].push_back(d);
    cout<<mi<<endl;
  }

  return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

set<ll> prime;

void prime_factorize(ll n) {
    ll l = sqrt(n);
    for (ll i = 1; i <= l; i++) {
        if (n % i == 0) {
            prime.insert(i); prime.insert(n / i);
        }
    }
}

ll factor(ll a, ll k) {
    return 5 * powl(a, 4) 
         - 10 * powl(a, 3) * k 
         + 10 * powl(a, 2) * powl(k, 2)
         - 5 * a * powl(k, 3)
         + powl(k, 4);
}

int main()
{
    ll x; cin >> x;
    prime_factorize(x);
    vll target;
    for (auto elem : prime) {
        target.push_back(elem); target.push_back(-elem);
    }

    sort(ALL(target));
    //for (auto elem : target) cout << elem << " "; cout << endl;

    for (auto k : target) {
        ll a = -1e3;
        //cout << k << " " << x / k << endl;
        for (ll a = -1e3; a <= 1e3; a++) {
            if (factor(a, k) == x / k) {
                cout << a << " " << a - k << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long MOD = 1000000007LL; // 998244353LL;

// Repeat
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
// Container Util
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort((v).begin(),(v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())

int main() {
    string W; cin >> W;
    map<char,int> m;
    int len = W.size();
    REP(i, len) m[W[i]]++;

    for (auto x : m) {
        if (x.second % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3624
n = int(input())
candidate = ['a']


def dfs(s, c):
    if len(s) == n:
        return
    for i in range(ord('a'), ord(c) + 2):
        now = s + chr(i)
        candidate.append(now)
        if i > ord(c):
            dfs(now, chr(i))
        else:
            dfs(now, c)


dfs('a', 'a')

for c in candidate:
    if len(c) == n:
        print(c)


Measured memory_bytes: 14556
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;


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

	cout << (X -= A) % B << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  string s;
  cin>>s;
  long k;
  cin>>k;

  int x=0;
  while(x<s.size() && s[x]=='1') x++;

  if(k <= x){
    cout << "1" << endl;
  } else {
    cout << s[x] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//                       _oo0oo_                         //
//                      o8888888o                        //
//                      88" . "88      ------ hzt1       //
//                      (| -_- |)                        //
//                      0\  =  /0                        //
//                    ___/`---'\___                      //
//                  .' \|     |// '.                     //
//                 / \|||  :  |||// \                    //
//                / _||||| -:- |||||- \                  //
//               |   | \  -  /// |     |                 //
//               | \_|  ''\---/''  |_/ |                 //
//               \  .-\__  '-'  ___/-. /                 //
//             ___'. .'  /--.--\  `. .'___               //
//          ."" '<  `.___\_<|>_/___.' >' "".             //
//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |           //
//         \  \ `_.   \_ __\ /__ _/   .-` /  /           //
//     =====`-.____`.___ \_____/___.-`___.-'=====        //
//                       `=---='                         //
//                                                       //
//                                                       //
//     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       //
//                                                       //
//                 God-He Bless All.                     //
//           This Code Will Never Explode.               //
//                                                       //
//                                                       //
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,Size,stdin);
        tail=(head=buffer)+l;
    }
    if(head==tail) return -1;
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=Getchar();
    for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
const int maxn=100010;
int n,L,T,A[maxn];
int main() {
	n=read();L=read();T=read();
	int p=0;
	rep(i,0,n-1) {
		int x=read(),f=read();
		if(f==1) {
			A[i]=(x+T)%L;
			(p+=(x+T)/L)%=n;
		}
		else {
			A[i]=((x-T)%L+L)%L;
			(p-=(L-1-x+T)/L)%=n;
		}
	}
	(p+=n)%=n;
	sort(A,A+n);
	rep(i,0,n-1) printf("%d\n",A[(i+p)%n]);
	return 0;
}


Measured memory_bytes: 1536
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int r, g, b;
    cin >> r >> g >> b;

    int v = r * 100 + g * 10 + b;

    if (v % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i] -= i;
	}
	nth_element(A.begin(), A.begin() + N / 2, A.end());
	int b = A[N/2];
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += abs(b - A[i]);
	}
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 1024
function main()
	a = parse.(split(readline()))
	if a[2] < 10
		c = a[1]*10+a[2]
	elseif a[2] < 100
		c = a[1]*100+a[2]
	else
		c = a[1]*1000+a[2]
	end
	
	x = round(Int, sqrt(c))
	if x*x == c
		print("Yes")
	else
		print("No")
	end
end
main()

Measured memory_bytes: 178708
#include "iostream"
#include "string.h"

using namespace std;

int L[1001][1001];

int lcs( char s1[], char s2[], int l1, int l2 ) {

	if (L[l1][l2] != 0)return L[l1][l2];

	if (l1 == 0 || l2 == 0) return 0;
	else if (s1[l1-1] == s2[l2-1]) L[l1][l2] = lcs(s1, s2, l1 - 1, l2 - 1) + 1;
	else {
		int lsc1 = lcs(s1, s2, l1 - 1, l2);
		int lsc2 = lcs(s1, s2, l1, l2 - 1);

		if (lsc1 > lsc2) L[l1][l2] = lsc1;
		else L[l1][l2] = lsc2;
	}

	return L[l1][l2];
}

int main() {

	int n;
	char s1[1000], s2[1000];

	cin >> n;

	int ans[150];

	for (int i = 0; i < n; i++) {
		cin >> s1;
		cin >> s2;

		int l1 = strlen(s1), l2 = strlen(s2);

		ans[i] = lcs(s1, s2, l1, l2);

		for (int j = 0; j <= l1; j++) {
			for (int k = 0; k <= l2; k++) {
				L[j][k] = 0;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 5196
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();;
		int W = sc.nextInt();
		String[] C = new String[H];
		for(int i = 0 ; i < H ; i++) {
			C[i] = sc.next();
		}
		for(int i = 0 ; i < H ; i++) {
			System.out.println(C[i]);
			System.out.println(C[i]);
		}
	}
}


Measured memory_bytes: 24788
a, b, n = map(int, input().split())

mx = 0

nn = n//b

mm = (a*n)//b - a*(nn)

if nn > 0:
    x = b*nn-1
    mx = (a*x)//b - a*(nn-1)
    mm = max(mm, mx)
    
print(mm)

Measured memory_bytes: 9120
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int k, a, b; cin >> k >> a >> b;
	if ((b / k) - ((a - 1) / k)) cout << "OK";
	else cout << "NG";

	return 0;
}

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

int main() {
    string s;
    cin >> s;

    int res = 1 << 30;

    for (int i = 0; i <= 1; i++){
        int start = i;
        int count = 0;

        for (int j = 0; j < s.size(); j++){
            if(s[j] - '0' != start) count++;
            start = 1 -start;
        }
        res = min(res, count);
    }

    cout << res << endl;

}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  string s;
  cin>>n>>s;
  ll ans=0;
  for(int i=0;i<n-2;i++){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      ans++;
    }
  }
  cout<<ans<<endl;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    Int y, x;
} p_t;

int main() {
    char c;
    cin >> c;
    dump(char(c + 1));
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
const int MOD=1e9+7;
struct mint{int x;mint(int x=0):x(x){}};
inline mint operator+  (mint a,mint b){return a.x+b.x<MOD?a.x+b.x:a.x+b.x-MOD;}
inline mint operator-  (mint a){return MOD-a.x;}
inline mint operator-  (mint a,mint b){return a+-b;}
inline mint operator*  (mint a,mint b){return 1LL*a.x*b.x%MOD;}
inline mint operator<< (mint x,int y){mint r=1;for(;y;y>>=1,x=x*x)if(y&1)r=r*x;return r;}
inline mint operator~  (mint x){return x<<MOD-2;}
inline mint operator/  (mint a,mint b){return a*~b;}
inline mint&operator+= (mint&a,mint b){return a=a+b;}
inline mint&operator-= (mint&a,mint b){return a=a-b;}
inline mint&operator*= (mint&a,mint b){return a=a*b;}
inline mint&operator<<=(mint&x,int y){return x=x<<y;}
inline mint&operator/= (mint&a,mint b){return a=a/b;}
#define MN 200000
#define MX 2001
mint f[MX*2][MX*2],F[MX*4+5],R[MX*4+5],ans;
int a[MN+5],b[MN+5];
inline mint C(int n,int m){return F[n]*R[m]*R[n-m];} 
int main()
{
	int n=read(),i,j;
	for(i=1;i<=n;++i)a[i]=read(),b[i]=read(),f[MX-a[i]][MX-b[i]]+=1;
	for(i=1;i<MX*2;++i)for(j=1;j<MX*2;++j)f[i][j]+=f[i-1][j]+f[i][j-1];
	for(F[0]=i=1;i<=MX*4;++i)F[i]=F[i-1]*i;
	for(R[i=MX*4]=~F[MX*4];i--;)R[i]=R[i+1]*(i+1);
	for(i=1;i<=n;++i)ans+=f[MX+a[i]][MX+b[i]]-C(a[i]+b[i]<<1,a[i]<<1);
	printf("%d",ans/2);
}

Measured memory_bytes: 64384
# D - AtCoder Express 2

import numpy as np
import sys

N, M, Q = map(int, input().split())
LRpq = np.array(sys.stdin.read().split(), np.int64)
L = LRpq[:2*M:2]
R = LRpq[1:2*M:2]
p = LRpq[2*M::2]
q = LRpq[2*M+1::2]
    
train = np.zeros((N+1, N+1))
np.add.at(train, (L,R), 1)

np.cumsum(train, axis = 0, out = train)
np.cumsum(train, axis = 1, out = train)
    
ans = train[q,q] - train[p-1,q] - train[q,p-1] + train[p-1,p-1]
for i in range(Q):
    print(int(ans[i]))

Measured memory_bytes: 66900
def get_mark(row, column)
    if row.odd? && column.odd? or row.even? && column.even?
        return '#'
    else
        return '.'
    end
end

loop do
    h,w = gets.split(' ').map(&:to_i)
    break if h==0 && w==0
    
    h.times do |row|
        s = ''
        w.times do |column|
            s += get_mark(row+1, column+1)
        end
        puts s
    end
    puts
end


Measured memory_bytes: 7252
s = input()
n = len(s)

def ok(s):
    n = len(s)
    for i in range(n//2):
        if s[i] != s[n-1-i]:
            return False
    return True

if ok(s) and ok(s[:n//2]) and ok(s[n//2+1:]):
        print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
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;}
#define MOD 1000000007 //998244353

ll N, W;
vl w(110), v(110);
matrix dp(110, vl(100100, -1));

ll f(ll i, ll j) {
    if(dp[i][j] >= 0) return dp[i][j];

    if(i==N) return 0;
    else if(w[i]>j) return f(i+1, j);
    else {
        dp[i][j] = max( v[i]+f(i+1, j-w[i]), f(i+1, j));
        return dp[i][j];
    }
}

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

    // solution comes here

    cin >> N >> W;
    rep(i, N) cin >> w[i] >> v[i];

    cout << f(0, W) << nl;
}


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

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




template <class T> class MinCostFlow {
public:
	class edge{
	public:
		int to;
		int capacity;
		T cost;
		int reve;

		edge(int _to,int _capacity, int _reve, T _cost){
			this->to = _to;
			this->capacity = _capacity;
			this->reve = _reve;
			this->cost = _cost;
		}
	};
	static const int MV = 3010;
	vector<edge> E[MV];
	T dist[MV];
	int prev_v[MV], prev_e[MV],NV;

	MinCostFlow(){
		init(MV);
	}
	void init(int NV = MV){
		this -> NV = NV;
		for(int i=0;i<MV;i++){
			E[i].clear();
		}
	}
	void addEdge(int x,int y,int cap, T cost){
		E[x].push_back(edge(y,cap,E[y].size(),cost));
		E[y].push_back(edge(x,0,E[x].size()-1,-cost));
	}
	T minCost(int from,int to,int flow){
		T res = 0;
		T inf = std::numeric_limits<T>::max()/2;
		memset(prev_v,0,sizeof(prev_v));
		memset(prev_e,0,sizeof(prev_e));
		while(flow>0){
			fill(dist,dist+NV,inf);
			dist[from]=0;
			bool up = true;
			while(up){
				up=false;
				for(int v=0;v<NV;++v){
					if(dist[v] == inf) continue;
					for(int i=0;i<E[v].size();++i){
						edge &e=E[v][i];
						if(e.capacity>0&&dist[e.to]>dist[v]+e.cost){
							dist[e.to]=dist[v]+e.cost;
							prev_v[e.to] = v;
							prev_e[e.to] = i;
							up=true;
						}
					}
				}
			}
			if(dist[to]==inf) return -1;
			int lc = flow;
			for(int v=to;v!=from;v=prev_v[v]){
				lc = min(lc, E[prev_v[v]][prev_e[v]].capacity);
			}
			flow -= lc;
			res += lc*dist[to];
			for(int v=to;v!=from;v=prev_v[v]){
				edge &e=E[prev_v[v]][prev_e[v]];
				e.capacity -= lc;
				E[v][e.reve].capacity += lc;
			}
		}
		return res;
	}
};

MinCostFlow<int> mf;

int main(){
	int n;
	cin>>n;
	vector<int> a(n),b(n);
	map<int,int> ma;
	rep(i,n){
		cin>>a[i]>>b[i];
		int ta;
		ta=ma.size();
		if(ma.count(a[i])==0) ma[a[i]]=ta;
		ta=ma.size();
		if(ma.count(b[i])==0) ma[b[i]]=ta;
	}
	int m = ma.size();
	int source = n+m;
	int sink = n+m+1;
	int MA = 1000000;
	rep(i,n){
		mf.addEdge(source,i,1,0);
		mf.addEdge(i,n+ma[a[i]],1,MA-b[i]);
		mf.addEdge(i,n+ma[b[i]],1,MA-a[i]);
	}
	for(auto x:ma){
		mf.addEdge(n+x.second,sink,1,0);
	}
	mf.addEdge(source,sink,n,MA);
	long long ans = mf.minCost(source,sink,n);
	int t = n-mf.E[source].back().capacity;
	// ans-=t*MA;
	ans-=(n)*MA;
	ans*=-1;
	cout<<ans<<endl;
}

Measured memory_bytes: 3588
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif 65 <= m + f < 80:
        print("B")
    elif 50 <= m + f < 65:
        print("C")
    elif 30 <= m + f < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


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

int main(){
    int n, m, l;
    cin >> n >> m >> l;
    double a[n+1][m+1] = {};
    double b[m+1][l+1] = {};
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++){
            cin >> b[i][j];
        }
    }

    double c[n+1][l+1] = {};
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            for(int k = 0; k < l; k++){
                c[i][k] += a[i][j] * b[j][k];
            }
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            if(j > 0) cout << " ";
            printf("%.0f", c[i][j]);
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define PB push_back
#define X first
#define Y second
#define INF 1000 * 1000 * 1000

#define LL long long
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;
const int MAX = 1 << 17;

int main()
{
	ios_base::sync_with_stdio(0);
	int N , A , B;
	cin >> N >> A >> B;
	cout << min(A , B) << " " << max(0 , A + B - N) << endl;
	
}


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

int N;
vector<int> L;

int main(void) {
	cin >> N;
	L.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> L[i];

	sort(L.begin(), L.end());
	int ans = 0;
	for (int i = 0; i < N - 2; ++i) {
		for (int j = i + 1; j < N - 1; ++j) {
			for (int k = j + 1; k < N; ++k) {
				if (L[k] < L[i] + L[j])
					++ans;
				if (L[k] >= L[i] + L[j])
					break;
			}
		}
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;
typedef pair<int, string> PSI;

int w, h, sx, sy, gx, gy;
int n, c, d, x, y;

int table[110][110];
int dis[110][110];

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

void solve(){
	REP(i, 110)REP(j, 110)dis[i][j] = INF;
	dis[sy][sx] = 0;

	queue<P> que;
	que.push(P(sy, sx));

	while (que.size()){
		P p = que.front(); que.pop();
		int cx = p.second, cy = p.first;

		if (y == gy&&x == gx)break;

		REP(i, 4){
			int nx = cx + dx[i], ny = cy + dy[i];
			if (nx >= 0 && nx < w&&ny >= 0 && ny < h){
				if (table[ny][nx] == table[cy][cx]
					&&dis[ny][nx] == INF){
					dis[ny][nx] = dis[cy][cx] + 1;
					que.push(P(ny, nx));
				}
			}
		}
	}
}

int main(){
	while (cin >> w >> h&&w + h){
		REP(i, 110)REP(j, 110){
			table[i][j] = 0;
		}
		cin >> sx >> sy >> gx >> gy;
		sx--;
		sy--;
		gx--;
		gy--;

		cin >> n;
		REP(i, n){
			cin >> c >> d >> x >> y;
			x--;
			y--;
			if (d == 0){
				REP(i, 2){
					REP(j, 4){
						table[y + i][x + j] = c;
					}
				}
			}
			else{
				REP(i, 4){
					REP(j, 2){
						table[y + i][x + j] = c;
					}
				}
			}
		}

		solve();

		if (dis[gy][gx] != INF&&table[sy][sx] != 0 && table[gy][gx] != 0)cout << "OK" << endl;
		else cout << "NG" << endl;
	}
}

//REP(i, h){
//	REP(j, w){
//		cout << table[i][j] << " ";
//	}
//	cout << endl;
//}
//cout << "!" << endl;
//solve();
//REP(i, h){
//	REP(j, w){
//		cout << dis[i][j] << " ";
//	}
//	cout << endl;
//}

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

using namespace std;

int main(void)
{
  int n_min,n_max;
  int m;
  int p;
  int result=0;
  
  vector <int> point;

  while(1)
    {
      cin >> m >> n_min >> n_max;
      if(m==0 && n_min==0 && n_max==0) break;

      for(int i=0;i<m;i++)
	{
	  cin >> p;
	  point.push_back(p);
	}

      sort(point.begin(),point.end(),greater<int>());

      int gap_max=0;
      int gap_tmp;
  
      for(int i=n_min;i<=n_max;i++)
	{
	  //cout << i << endl;
	  if(i!=0)
	    {
	      gap_tmp = point[i-1]-point[i];
	      if(gap_tmp>=gap_max && i > result)
		{
		  gap_max=gap_tmp;
		  result=i;
		}
	    }
	}

      cout << result << endl;

      gap_max=0;
      result=0;
      point.clear();
    }
  return 0;

}


Measured memory_bytes: 3116
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin>>N;
    string S[N];
    int ac=0,wa=0,tle=0,re=0;
    for(int i=0;i<N;i++){
        cin>>S[i];
        if(S[i]=="AC"){
            ac++;
        }
        else if(S[i]=="WA"){
            wa++;
        }
        else if(S[i]=="TLE"){
            tle++;
        }
        else if(S[i]=="RE"){
            re++;
        }
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}


Measured memory_bytes: 6720
#include <stdio.h>

int main(void) {
	long long int n, r = 0, g = 0, b = 0, i, j; 
	long long int num;
	int k;
	int a[8001];
	char s[8001];

	scanf("%d", &n);
	scanf("%s", s);

	for (i = 0; i < n; i++) {
		switch (s[i]) {
		case 'R':
			r++;
			a[i] = 0;
			break;
		case 'G':
			g++;
			a[i] = 1;
			break;
		case 'B':
			b++;
			a[i] = 2;
			break;
		}
	}

	num = r * b * g;

	for (j = 0; j < n; j++) {
		for (i = 0; i < j; i++) {
			k = j + (j - i);
			if (k < n) {
				if (a[i] == a[j])
					continue;
				if (a[j] == a[k])
					continue;
				if (a[k] == a[i])
					continue;

				num--;
			}
		}
	}

	printf("%lld", num);

	return 0;
}



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

int main() {
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	b-=a;
	if (c>d) swap(c,d);
	bool chk=false;
	for (int i=0;i<n;++i) {
		long long r=1LL*i*d-1LL*(n-1-i)*c;
		long long l=1LL*i*c-1LL*(n-1-i)*d;
		if (b>=l&&b<=r) chk=true;
	}
	if (chk) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import sys
import math
def search_divisor_num_1(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        divisor_num = 1
        for prime in prime_list:
            count = 1
            while num % prime == 0:
                num //= prime
                count += 1
            divisor_num *= count

        if num != 1:
            divisor_num *= 2

        return divisor_num

def make_prime_list_2(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]
    
n = int(input())
count =0
for i in range(1,n+1,2):
    tmp = search_divisor_num_1(i)
    if tmp == 8:
        count+=1
print(count)

Measured memory_bytes: 3064
#include <iostream>

int main(int argc, char *argv[]) {
    int a, b;
    std::cin >> a >> b;
    int k = (a + b) / 2;
    if (k * 2 == a + b)
        std::cout << k << std::endl;
    else
        std::cout << "IMPOSSIBLE" << std::endl;
}


Measured memory_bytes: 256
def calc(n):
    if n % 4 == 1:
        return 1
    elif n % 4 == 2:
        return 1 ^ n
    elif n % 4 == 3:
        return 0
    else:
        return 0 ^ n


A, B = map(int, input().split())
print(calc(B) ^ calc(A - 1))


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

int main(int argc, char** argv) {
  int N;
  std::cin >> N;
  std::vector<long> L(N);
  for (auto& e : L) std::cin >> e;

  std::sort(L.begin(), L.end(), std::greater<long>());
  long long cnt {};
  for (auto i = 0;i < N;++i) {
    for (auto j = i+1;j < N;++j) {
      int k {};
      int c = L[i] - L[j];
      for (k = j+1;k < N;++k) {
        if (L[k] <= c) break;
      }
      cnt += (k-j-1);
    }
  }
  std::cout << cnt << '\n';
}


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

int main(void)
{
    int n, i, j, flag = 0;
    cin >> n;
    vector<string> w(n);
    for(i = 0; i < n; i++) {
        cin >> w.at(i);
        for(j = 0; j < i; j++) {
            if(w.at(i) == w.at(j)) flag = 1;
        }
    }

    for(i = 0; i < n - 1; i++) {
        if( w.at(i).at(w.at(i).size() - 1) != w.at(i + 1).at(0)) {
            flag = 1;
            break;
        }
    }
    if (flag == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC137.GreenBin();
        }
    }

    class ABC137
    {
        public static void GreenBin()
        {
            int n = int.Parse(Console.ReadLine());
            var s = Input.getStringArray(n);
            var dic = new Dictionary<string,long>();
            long cnt = 0;
            for(int i=0; i<n; i++)
            {
                var a = s[i].ToCharArray();
                Array.Sort(a);
                string str = new string (a);
                if(dic.ContainsKey(str))
                {
                    dic.TryGetValue(str,out cnt);
                    cnt ++;
                    dic[str] = cnt;
                }
                else
                {
                    dic.Add(str,1);
                }                            
            }
            cnt = dic.Values.Select(x=>x*(x-1)/2).Sum();
            Console.WriteLine(cnt);
        }
    }

    class Input
    {
        public static int getInt()
        {
            int i = int.Parse(Console.ReadLine());
            return i;
        }

        public static string getString()
        {
            string s = Console.ReadLine();
            return s;
        }
        public static int[] getIntArray()
        {
            string[] s = Console.ReadLine().Split(' ');
            int[] num = s.Select(x=>int.Parse(x)).ToArray();
            return num;
        }
        public static long[] getLongArray()
        {
            string[] s = Console.ReadLine().Split(' ');
            long[] num = s.Select(x=>long.Parse(x)).ToArray();
            return num;
        }
        public static string[] getStringArray(int n)
        {
            var s = new string[n];
            for(int i=0; i<n; i++)
            {
                s[i] = Console.ReadLine();
            }
            return s;
        }
    }
}


Measured memory_bytes: 36436
import java.util.*;
import java.io.*;
import java.lang.Math;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong();
    long attacks = 0;
    long temp =1;
    while(h>0){
      attacks+=temp;
      temp*=2;
      h/=2;
    }
    System.out.println(attacks);
  }
}
      
      


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

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

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int buttons[n];
  bool buttonsYet[n];
  rep(i, n) {
    cin >> buttons[i];
    buttonsYet[i] = false;
  }

  int go = 0;
  int cnt = 0;
  while (true) {
    go = buttons[go] - 1;
    cnt++;
    if (go == 1) {
      cout << cnt << endl;
      return 0;
    } else if (buttonsYet[go] == true) {
      cout << -1 << endl;
      return 0;
    }
    buttonsYet[go] = true;
  }
  return 0;
}

Measured memory_bytes: 768
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

int N;
vector<LL> A;

LL ans = 0;
vector<pair<LL,LL>> manip;

void solve(){
	sort(A.begin(),A.end());
	vector<LL> neg,pos;
	for(int i=0;i<N;i++){
		if(A[i]<0) neg.push_back(A[i]);
		else pos.push_back(A[i]);
	}

	if(neg.size()==0){
		LL sum = pos[0];
		for(int i=1;i<pos.size()-1;i++){
			manip.push_back(pair<LL,LL>(sum,pos[i]));
			sum -= pos[i];
		}
		manip.push_back(pair<LL,LL>(pos[pos.size()-1],sum));
		ans = pos[pos.size()-1]-sum;
		return;
	}
	if(pos.size()==0){
		LL sum = neg[neg.size()-1];
		for(int i=neg.size()-2;i>=0;i--){
			manip.push_back(pair<LL,LL>(sum,neg[i]));
			sum -= neg[i];
		}
		ans = sum;
		return;
	}

	LL sum = neg[0];
	for(int i=0;i<pos.size()-1;i++){
		manip.push_back(pair<LL,LL>(sum,pos[i]));
		sum -= pos[i];
	}
	manip.push_back(pair<LL,LL>(pos[pos.size()-1],sum));
	sum = pos[pos.size()-1] - sum;
	for(int i=neg.size()-1;i>=1;i--){
		manip.push_back(pair<LL,LL>(sum,neg[i]));
		sum -= neg[i];
	}
	ans = sum;
}
 
int main(){
    cin >> N;
    A = vector<LL>(N);
    for(int i=0;i<N;i++) cin >> A[i];
 
    solve();

	cout << ans << endl;
    for(int i=0;i<manip.size();i++) {
    	cout << manip[i].first << " " << manip[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 5260
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int[] N = {111, 222, 333, 444, 555, 666, 777, 888, 999};

		for(int i = 0;i < N.length; i++) {
			if(N[i] == n) {
				System.out.println(N[i]);
				break;
			} else if(N[0] > n) {
				System.out.println(N[0]);
				break;
			} else if(N[i] < n && n < N[i + 1]) {
				System.out.println(N[i + 1]);
				break;
			}
		}


	}
}

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

int main(){
  int N;
  cin >> N;
  int digit = log10(N);
  int ans = 0;
  if(digit == 0){
    ans += N;
  }else if(digit == 1){
    ans += 9;
  }else if(digit == 2){
    ans += 9;
    ans += N - 99;
  }else if(digit == 3){
    ans += 9;
    ans += 900;
  }else if(digit == 4){
    ans += 9;
    ans += 900;
    ans += N - 9999;
  }else if(digit == 5){
    ans += 9;
    ans += 900;
    ans += 90000;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
import sys

input = sys.stdin.readline

def main():
    a, b, c = map(int, input().split())
    
    A = []
    
    for i in range(a):
        ai = list(map(int, input().split()))
        A.append(ai)
    B = []
    for i in range(b):
        bi = list(map(int, input().split()))
        B.append(bi)
    
    temp = 0
    for i in range(a):
        for k in range(c):
            temp = 0
            for m in range(b):
                temp += A[i][m] * B[m][k]
            print(temp, end ="")
            if k == c-1:
                print("")
            else:
                print(" ", end = "")
        
if __name__ == "__main__":
    main()
    


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

int main(){
  double count=0;
  int N;
  cin>>N;
  vector<double>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
    count+=1/A[i];
  }
  count=1/count;
cout<<count;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if (a >= 13)
    {
        cout << b << endl;
        return 0;
    }
    else if (6 <= a && a <= 12)
    {
        cout << b / 2 << endl;
        return 0;
    }
    else if (a <= 5)
    {
        cout << "0" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int a, b, c, d;
    int start, end, during;
    cin >> a >> b >> c >> d;

    start = max(a, c);
    end = min(b, d);

    during = end - start > 0 ? end - start : 0;

    cout << during << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

signed main()
{
	string s;
	cin >> s;
	int ans = 0;
	REP(i, s.length())
	{
		if (s[i] == '+') ans++; else ans--;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3168
#include<stdio.h>
int main(void){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if ((a&1)&&(b&1)&&(c&1)){
		long long min=1ll *a *b;
		if (min>1ll*b*c) min=1ll*b*c;
		if (min>1ll*a*c) min=1ll*a*c;
		printf("%lld",min);
	}
	else {
		printf("0");
	}
}

Measured memory_bytes: 128
n = gets.to_i; c = gets.split.map(&:to_i)
  
for i in 1..80000000 do
    ok = true
    for j in 0..(n - 1) do
        if c[j] % i != 0 then
            ok = false
        end
    end
    if ok == true then
        p i
    end
end

Measured memory_bytes: 8780
n = int(input())
l = list(map(int, input().split()))

d = {0:0, 1:0, 2:0, 3:0}
for a in l:
  a = a%4
  d[a] += 1

if d[1]+d[3] > d[0]+1:
  print('No')
elif d[1]+d[3] == d[0]+1 and d[2] > 0:
  print('No')
else:
  print('Yes')
  



Measured memory_bytes: 62576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int x = N;
  int total = 0;
  for (int i = 0; 9 > i; i++){
    total += x % 10;
    x /= 10;
  	if (x == 10){
      total += 1;
      break;
    }
    else if(x < 10){
      total += x;
      break;
    }
  }
  if (N % total == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

max_ = 0
for a in range(K + 1):
    for b in range(K - a + 1):
        if a + b > N:
            continue

        jwl = V[:a]
        jwl += V[N - b:]
        rmv = K - (a + b)
        jwl.sort()

        sum_ = sum(jwl)
        for i in range(min(rmv, len(jwl))):
            if jwl[i] >= 0:
                break

            sum_ -= jwl[i]

        max_ = max(max_, sum_)


print(max_)


Measured memory_bytes: 3064
#include<stdio.h>

int main(void){

  int N , T , A;
  scanf("%d %d %d", &N , &T , &A);
  int H , dif;
  int close_num = 0;
  int most_close = 1000000000;

  for(int i = 0 ; i < N ; i++){
    scanf("%d", &H);                  //標高入力
    
    dif = A * 1000 - (T * 1000 - H * 6);        //気温差(小数を無視するために1000倍)

      if(dif < 0)   dif *= -1;          //気温差を絶対値変換
      
        if(dif < most_close){
        most_close = dif;               //最小値保存
        close_num = i + 1;              //最小値の番号保存
        }
    }
    

  printf("%d",close_num);


  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,ii ) for( typeof(gg.begin()) ii=gg.begin();ii!=gg.end();ii++)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define sz(a) int((a).size())
#define N 100010
#define MAX 30
#define mod 1000000007
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define all(a) a.begin(),a.end()
const ll INF = 1e18+1;

set <pii> s,colo;
map <pii, int> m;
ll ans[N];

int main()
{
	int n,h,w,a,b,val;
	ll sum=0;
	scanf("%d%d%d",&h,&w,&n);
	REP(i,n)
	{
		scanf("%d%d",&a,&b);
		colo.insert(mp(a,b));
	}
	foreach(colo,ii)
	{
		a=ii->X;
		b=ii->Y;
		REPP(row,max(a-2,1),min(a+1,h-1))
			REPP(col,max(b-2,1),min(b+1,w-1))
			{
				if (s.find(mp(row,col))!=s.end()) continue;
				s.insert(mp(row,col));
				val=0;
				REPP(j,row,row+3)
					REPP(k,col,col+3)
					{
						if (colo.find(mp(j,k))!=colo.end())
							val++;
					}
				sum++;
				m[mp(row,col)]=val;
			}
	}
	foreach(m,ii)
		ans[ii->Y]++;
	ans[0]=1ll*(h-2)*(w-2)-sum;
	REP(i,10) printf("%lld\n",ans[i]);
return 0;
}


Measured memory_bytes: 103424
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N,M,P,X,sum=0;
  vector<int> T(100);
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> T.at(i);
    sum+=T.at(i);
  }
  cin >> M;
  for(int j=0;j<M;j++){
    cin >> P >> X;
    cout << sum-T.at(P-1)+X << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,i,j,k;
  double dp[110][110],d[110][110],max;
  while(scanf("%d %d",&n,&m),n||m){
    for(i=0;i<n;i++){
      for(j=0;j<n;j++)scanf("%lf",&d[i][j]);
      dp[0][i]=1;
    }
    for(k=1;k<m;k++){
      for(i=0;i<n;i++){
	for(j=max=0;j<n;j++){
	  if(max<dp[k-1][j]*d[j][i])max=dp[k-1][j]*d[j][i];
	}
	dp[k][i]=max;
      }
    }
    max=0;
    for(i=0;i<n;i++){
      if(max<dp[m-1][i])max=dp[m-1][i];
    }
    printf("%.2f\n",max);
  }
  return 0;
}
      
      
  

Measured memory_bytes: 844
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

signed main(){
    
    int n, k; cin >> n >> k;
    for(int i = 0; i < n; i++){ int a; cin >> a; }
    n--;
    k--;
    cout << (n + k - 1) / k << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> Bi;
  
  rep(i,N){
    int tmpBi = 0;
    cin >> tmpBi;
    Bi.push_back(tmpBi);
  }

  vector<int> Ai(N);
  
  //後ろからAiを決定していく方針
  //末端
  Ai.at(N - 1) = Bi.at(N - 2);
  
  for(int i = N - 2;i > 0;i--){
    Ai.at(i) = min(Bi.at(i), Bi.at(i-1));
  }
  
  Ai.at(0) = Bi.at(0);
  int ans = 0;
  ans = accumulate(Ai.begin(), Ai.end(), 0);
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256