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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

void Main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  vector<int> k(m);
  rep(i, m) {
    cin >> k[i];
    rep(j, k[i]) {
      int sij;
      cin >> sij;
      --sij;
      s[i].push_back(sij);
    }
  }
  vector<int> p(m);
  for (auto &&pi : p) {
    cin >> pi;
  }

  int ans = 0;
  for (int bit = 0; bit < (1 << n); ++bit) {
    bool flag = true;
    rep(i, m){
      int on_sum = 0;
      rep(j, k[i]){
        if (bit & (1 << s[i][j])) {
            ++on_sum;
        }
      }
      if (on_sum % 2 != p[i]) {
        flag = false;
      }
    }
    if (flag == true) {
      ++ans;
    }
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin >> a >> b;
  if((a*b) & 1) {
    cout << "Odd" << "\n";
  }else{
    cout << "Even" << "\n";
  }
}

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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    vi arr(n);
    for (int i = 0; i < n; i++){
        cin >> arr[i];
        arr[i]--;
    }
    vi ans(n * n, -1);
    vi rv(n + 1);
    vi place(n + 1);
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    for (int i = 0; i < n; i++){
        ans[arr[i]] = i + 1;
        rv[i + 1] = n - 1 - i;
        place[i + 1] = arr[i];
        for (int j = 0; j < i; j++)
            pq.emplace(arr[i], i + 1);
    }
    vi left;
    bool poss = true;
    for (int i = 0; i < n*n; i++){
//        debug(ans);
        if (ans[i] != -1) {
            for (int j = 0; j < rv[ans[i]]; j++){
                left.push_back(ans[i]);
            }
        } else {
            if (!pq.empty()){
                pii p = pq.top(); pq.pop();
                if (place[p.Y] <= i) {
                    poss = false;
                    break;
                }
                ans[i] = p.Y;
            } else {
                if (left.empty()){
                    poss = false;
                    break;
                }
                ans[i] = left.back();
                left.pop_back();
            }
        }
    }
    if (!poss) cout << "No" << endl;
    else {
        cout << "Yes" << endl;
        for (int x : ans)
            cout << x << ' ';
        cout << endl;
    }



}


Measured memory_bytes: 4212
import itertools
n = int(input())
s = input()

d = {
    'R': [0],
    'G': [0],
    'B': [0]
}

for i in reversed(range(n)):
    for c in 'RGB':
        if s[i] == c:
            d[c].append(d[c][-1]+1)
        else:
            d[c].append(d[c][-1])
ans = 0

for c1, c2, c3 in itertools.permutations(['R', 'G', 'B'], 3):
    for i in range(n):
        if s[i] == c1:
            for j in range(i+1, n-1):
                if s[j] == c2:
                    ans += d[c3][-j-1]
                    l = 2 * j -i
                    if l < n and s[l] == c3:
                        ans -= 1
    
print(ans)


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

int main() {
  int N;
  cin >> N;
  int a = N / 1000;
  int b = (N - a * 1000) / 100;
  int c = (N - a * 1000 - b * 100) / 10;
  int d = (N - a * 1000 - b * 100 - c * 10 );
  
  if (a == b) {
    if (b == c) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else if (b == c) {
    if (c == d) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    cout << "No" << endl;
  }
}


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

int main() {
	int n,a[100001],ct=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++){
		if(a[i]==i+1){
			a[i+1]=a[i];
			ct++;
		}
	}
	cout<<ct;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int main(){

int n,y;
cin >> n >> y;
for(int i = 0; i <= n; i++){
for(int j = 0; i + j <= n; j++){
int k = n - (i + j);
if (i * 10000 + j * 5000 + k * 1000 == y){
cout << i << " " << j << " " << k << endl;
goto end;
}
}
}

  cout << "-1 -1 -1" << endl;
  end:
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

using Graph = vector<vector<int>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


int main() {

    int N;
    cin >> N;
    vector<int> L(N);
    REP(i, N)cin >> L[i];
    int a, b;
    int ans = 0;

    sort(L.begin(), L.end());

    for(int i = 0;i < N; i++){
        a = L[i];
        for(int j = i+1;j < N; j++){
            b = L[j];
            auto left = L.begin()+j;
            auto right = L.begin() + N;
            auto ite = lower_bound(left, right, a+b);
            // cout << a << " " << b << " " <<  ite - left - 1 << endl;
            ans += ite - left - 1;
        }
    }
    cout << ans << endl;


         

    
    return 0;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  cout << max(C - (A - B), 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int h,w,k,i,j,cnt,ans=0;
  cin>>h>>w>>k;
  vector<string> c(h);
  for(i=0;i<h;i++) cin>>c.at(i);
  for(i=0;i<(1<<h);i++){
    bitset<6> bi(i);
    for(j=0;j<(1<<w);j++){
      bitset<6> bj(j);
      cnt=0;
      for(int l=0;l<h;l++){
        for(int m=0;m<w;m++){
          if(bi.test(l)&&bj.test(m)&&c.at(l).at(m)=='#') cnt++;
        }
      }
      if(cnt==k) ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
/* */

#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp("%s = %s\n", #x, to_string(x).data())
string to_string (char s) { return string(1, s); }
string to_string (string s) { return "\"" + s + "\""; }
template<typename T> string to_string (vector<T>);
template<typename U, typename V> string to_string (pair<U, V> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template<typename T> string to_string (vector<T> v) {
	string res = "["; for (int i = 0; i < (int)v.size() - 1; i++) res += to_string(v[i]) + ", ";
	if (!v.empty()) res += to_string(v.back());	res += "]"; return res; }

ll n;

int nd (ll x) {
	int res = 0;
	while (x) { res++; x /= 10; }
	return res;
}

int solve () {
	int ans = (int)1e9;
	for (ll i = 1; i * i <= n; i++) if (n % i == 0) {
		ans = min(ans, max(nd(i), nd(n / i)));
	}
	return ans;
}

int main () { 
#ifdef XVENOM
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
#endif

	scanf("%lld", &n);
	printf("%d\n", solve());
}

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

typedef long long ll;
#define reg register
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)

char IO;
int rd(){
	int s=0,f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}

const int N=1e5+10;





int main(){
	int x=rd();
	cout<<3ll*x*x;
}


















Measured memory_bytes: 256
def kaibun(S):
    for i in range(len(S)//2):
        if S[i] != S[-i-1]:
            return False
    return True
S = input()

if kaibun(S):
    if kaibun(S[:(len(S)-1) // 2]):
        if kaibun(S[(len(S)+3-1) // 2:]):
            print('Yes')
            exit()

print('No')


Measured memory_bytes: 3060
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int f[N];
int find(int x){
  return f[x]==x?x:(f[x]=find(f[x]));
}
int n,m;
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>m;
  for(int i=1;i<=n;i++)f[i]=i;
  for(int i=1;i<=m;i++){
    int s,t;
    cin>>s>>t;
    f[find(s)]=find(t);
  }
  set<int>s;
  for(int i=1;i<=n;i++)s.insert(find(i));
  int ok=s.size();
  cout<<ok-1;
  return 0;
}

Measured memory_bytes: 7920
count = gets.to_i
cards = gets.chomp.split(' ').map(&:to_i)

sorted_cards = cards.sort.reverse
alice_sum = 0
bob_sum = 0

sorted_cards.each.with_index(1) do |card, i|
  alice_sum += card if i.odd?
  bob_sum += card if i.even?
end

p alice_sum - bob_sum


Measured memory_bytes: 1788
void main() {
	auto N = ri;
	auto P = readAs!(long[]);
	auto arr = new long[](N);
	arr[0] = P[0];
	foreach(i; 1..N) {
		arr[i] = min(arr[i-1], P[i]);
	}
	ulong res;
	foreach(i; 0..N) {
		if(arr[i] >= P[i]) res++;
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 11536
N = int(input())
a = [int(input()) for i in range(N)]
now = a[0]
count = 1
c = 0
for i in range(10**6):
    if now != 2:
        count += 1
        now = a[now - 1]
    else:
        print(count)
        c = 1
        break
if c == 0:
    print(-1)

Measured memory_bytes: 7084
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 1020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll GCD(ll a, ll b){
	if(b==0) return a;
	else return GCD(b,a%b);
}

int main(){
	int n; cin >> n;
	int M = 1e6;
	vector<int> b(M+1,0);
	vb visit(M+1,0);
	int gc = 0;
	rep(i,n){
		int a; cin >> a;
		gc = GCD(gc,a);
		b[a]++;
	}
	if(gc > 1){
		cout << "not coprime" << "\n";
		return 0;
	}
	for(int i=2; i<=M; i++){
		if(visit[i]) continue;
		int a = 0;
		for(int j=i; j<=M; j+=i){
			visit[j] = 1;
			a += b[j];
		}
		if(a >= 2){
			cout << "setwise coprime" << "\n";
			return 0;
		}
	}
	cout << "pairwise coprime" << "\n";
}

Measured memory_bytes: 7156
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    long long N;
    cin >> N;
    vector<long long> s(N);
    long long ans = 0;
    for(int i = 0; i < N; i++){
        long long a, b;
        cin >> a >> b;
        ans -= b;
        s[i] = a + b;
    }
    sort(s.begin(), s.end());
    int f = 0;
    for(int i = 0; i < N; i++){
        if(f % 2 == 0) ans += s[N - 1 - i];
        f++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import sys
n=int(input())
if n<10:
    print(1)
    sys.exit()
ans=float("inf")
for i in range(1,int(n**(1/2))+1):
    if n%i==0:
        ans=min(ans,max(len(str(int(n//i))),len(str(i))))
print(ans)

Measured memory_bytes: 3188
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <iostream>
using namespace std;

priority_queue<int> items;


int main()
{
    int n,m;scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++)
    {
        int tmp;scanf("%d",&tmp);
        items.push(tmp);
    }
    for (int i=0;i<m;i++)
    {
        int tmp=items.top();items.pop();
        tmp/=2;items.push(tmp);
    }
    long long ans=0;
    while (!items.empty())
    {
        ans+=items.top();
        items.pop();
    }
    cout << ans;

}


Measured memory_bytes: 892
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int B = sc.nextInt();
      if(B%A==0){
        System.out.println(A+B);
      }else{
        System.out.println(B-A);
      }
    }
}

Measured memory_bytes: 35776
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

int H, W, K;
int greedy(vector<int> pnt, vector<vector<int> > &choco){
    int N=pnt.size();
    int ret=N;
    vector<int> cnt(N+1,0);
    
    pnt.push_back(MOD);
    vector<int> pntW(0);
    bool flag=false;
    for(int i=0; i<W; i++){
        int h=0;
        for(int j=0; j<H; j++){
            if(j>=pnt[h]){
                h++;
            }
            cnt[h]+=choco[j][i];

            if(cnt[h]>K){
                if(flag==true){
                    /*
                    cout_vec(pnt);
                    cout_vec(cnt);
                    cout << h << endl;
                    */
                    return MOD;
                }else{
                    ret++;
                    cnt=vector<int>(N+1,0);
                    i--;
                    flag=true;
                    pntW.push_back(i+1);
                    goto point;
                }
            }
        }
        flag=false;
        point:
            ;
    }
    /*
    if(ret<MOD){
        cout_vec(pnt);
        cout_vec(pntW);
        cout << endl;
    }
    */
    
    
    return ret;
}

int full_search(int n, vector<int> &pnt, vector<vector<int> > &choco){
    if(n==H){
        return greedy(pnt, choco);
    }
    int ret=MOD;
    pnt.push_back(n);
    ret=min(ret,full_search(n+1, pnt, choco));
    pnt.pop_back();
    ret=min(ret,full_search(n+1, pnt, choco));

    return ret;
}

int main(){
    cin >> H >> W >> K;
    vector<vector<int> > choco(H,vector<int>(W,0));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            char c;
            cin >> c;
            choco[i][j]=c-'0';
        }
    }
    vector<int> pnt(0);
    cout << full_search(1, pnt, choco) << endl;

}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

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

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    int n, m;
    cin >> n >> m;
    vector<int> gg(n, 0);
    vector<int> cnt(n, 0);

    int ans1 = 0, ans2 = 0;
    while (m--) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (s == "WA") {
            if (!gg[p]) {
                cnt[p]++;
            }
        }else {
            if (!gg[p]) {
                ans2 += cnt[p];
                ans1++;
                gg[p] = 1;
            }
        }
    }
    cout << ans1 << " " << ans2;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#define NIL -1
#define WHITE 0
#define BLACK 1
static const int MAX = 500;
static const int INF = (1<<21);

int main(void){
  int n, i, j, e, sum;
  int u, v;
  int minv;
  int M[MAX][MAX];
  int check[MAX];
  int p[MAX];
  int key[MAX];
  
  scanf("%d", &n);

  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INF:e;
    }
  }


  for(i = 0;i < n;i++){
    key[i] = INF;
    p[i] = NIL;

    //まだ訪れてない
    check[i] = WHITE;
  }


  key[0] = 0;
  sum = 0;
  while(1){
    u = NIL;  
    minv = INF;

    //コストの少ないのーどみつける
    for(i = 0;i < n;i++){
      if(key[i] < minv && check[i] == WHITE){
	u = i;
	minv = key[i];
      }
    }

    if(u == NIL)
      break;  

    //使ったことにする    
    check[u] = BLACK;
    sum += key[u];

    //隣接するそれぞれののーどに重みを入れる
    for(v = 0;v < n;v++){
      if(M[u][v] < key[v]){
	key[v] = M[u][v];
	p[v] = u;
      }
    }
  }  

  printf("%d\n",sum);
  
  return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<P, P> PPP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX

#define MAX_N 1000000001

int main(){
    cin.sync_with_stdio(false);
    int n, t;
    cin >> n >> t;

    int a[n];
    PIP cities[n];

    int maximum = 0, minimum = MAX_N, j = 0;
    int count[n] = {};
    rep(i, n) {
        cin >> a[i];
        if (minimum >= a[i]) {
            minimum = a[i];
            j = i;
        }
        cities[i].fi = a[i] - minimum;
        cities[i].se.fi = j;
        cities[i].se.se = i;
        count[j]++;
        count[i]++;
    }

    sort(cities, cities + n, greater<PIP>());
    /*rep(i, n) {
        cout << cities[i].se.fi << ", " << cities[i].se.se << endl;
    }*/


    int d = cities[0].fi;
    int cnt = 0;
    set<int> set;
    rep(i, n) {
        if (cities[i].fi != d) break;
        auto it1 = set.find(cities[i].se.fi), it2 = set.find(cities[i].se.se);
        if (it1 != set.end()) {
            count[cities[i].se.se]--;
            continue;
        }
        if (it2 != set.end()) {
            count[cities[i].se.fi]--;
            continue;
        }
        if (count[cities[i].se.fi] > count[cities[i].se.se]) {
            cnt += count[cities[i].se.fi];
            count[cities[i].se.se]--;
            set.insert(cities[i].se.fi);
            // cout << "a insert: " << cities[i].se.fi << endl;
        } else {
            cnt += count[cities[i].se.se];
            count[cities[i].se.fi]--;
            set.insert(cities[i].se.se);
            // cout << "b insert: " << cities[i].se.se << endl;
        }
    }

    cout << set.size() << endl;

    return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    long b=0;
    long j=0;
    for(int i=0;i<S.size();i++){
        if(S.at(i)=='B'){
            b++;
        }
        else j+= b;
    }
    cout << j << endl;
}

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

#define se second
#define fi first
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    k /= 1000;

    int x = -1, y = -1, z = -1;
    for (int i = 0; 4*i <= k-n; i++){
        if ((k-n-4*i)%9 == 0 && (k-n-4*i)/9 >= 0 && n-(k-n-4*i)/9-i >= 0){
            y = i;
            z = (k-n-4*i)/9;
            x = n-y-z;
            break;
        }
    }

    printf("%d %d %d\n", z, y, x);
    return 0;
}


Measured memory_bytes: 256
import math
def is_prime(number):
    """ ?????????????????´??°???????´???°???????????????????????? """
    if number == 2:
        return True
    if number < 2 or number%2 == 0:
        return False
    i = 3
    while i < math.sqrt(number) + 1:
        if number%i == 0:
            return False
        i = i + 2
    return True

COUNTER = 0
while 1:
    try:
        N = int(input())
        if is_prime(N):
            COUNTER += 1
    except EOFError:
        break

print(COUNTER)

Measured memory_bytes: 7788
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x =((x%MOD)+(y%MOD))%MOD;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return ((x%MOD)*(y%MOD))% MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
        string str,ptr;
        cin>>str>>ptr;
        lld ans=LLONG_MAX;
        for(lld i=0;i<str.length();i++)
        {

            lld ctr=0;
            if(i+ptr.length()-1>=str.length())
                break;
            for(lld j=i;j<i+ptr.length();j++)
                if(str[j]!=ptr[j-i])
                ctr++;
            ans=min(ans,ctr);
            //cout<<ctr<<endl;
        }
        cout<<ans<<endl;
    }

}





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

using namespace std;

long long int max(long long int a, long long int b){
	if (a < b)
		return b;
	else
		return a;
}

int main(void){
	long long int n, k;

	cin >> n >> k;


	long long int num = 0;

	for (long long int b = k+1; b <= n; b++){
		num += (b-k)*((n+1)/b);

//		if (b != 1)
			num = num + max(0, (n - b*((n+1)/b) - k + 1));
//		else 
//			num += (n - b*((n+1)/b) - k + 1);
	}

	if (k == 0)
		num -= n;


	cout << num << endl;
}

Measured memory_bytes: 256
from fractions import gcd
n=int(input())
l=[int(input()) for i in range(n)]
if n==1:
    print(l[0])
elif n==2:
    x=gcd(l[0],l[1])
    print(l[0]*l[1]//x)
else:
    g=gcd(l[0],l[1])
    lcm=l[0]*l[1]//g
    for i in range(2,n):
        g=gcd(lcm,l[i])
        lcm=lcm*l[i]//g
    print(lcm)

Measured memory_bytes: 5432
#include <iostream>
#include <vector>
#define Graph vector<vector<int>>
using namespace std;

Graph edge(8, vector<int> (8));

// 現在の頂点, 頂点の数, 訪問済みの真偽
int dfs(int v, int n, bool* visited) {
	bool all_visited = true;
	for (int i = 0; i < n; i++) {
		if (visited[i] == false) {
			all_visited = false;
			break;
		}
	}
	// すべての頂点が訪問済みなら1を返す
	if (all_visited)
		return 1;
  
	int ans = 0;
	for (int i = 0; i < n; i++) {
		// 辺が存在しない、または訪問済みならとばす
		if (edge[v][i] == false)
			continue;
		if (visited[i])
			continue;

		visited[i] = true;
		ans += dfs(i, n, visited);
		// ここで未訪問に戻さないと、1通り目で全ての頂点が訪問済みになり、2回目以降がカウントできなくなる
		visited[i] = false;
	}
  
	return ans;
}

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		// 頂点a-1, b-1間を繋ぐ辺が存在する
		edge[a - 1][b - 1] = true;
		edge[b - 1][a - 1] = true;
	}
  
	// 全ての頂点を未訪問に設定
	bool visited[8];
	for (int i = 0; i < n; i++)
		visited[i] = false;
  
	visited[0] = true;
	int ans = dfs(0, n, visited);
	cout << ans << endl;
  
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  while(n--){
    string a,b; cin >> a >> b;
    if(a.size() > 80 || b.size() > 80){
      cout << "overflow" << endl;
      continue;
    }
    if(a.size() < b.size()) swap(a,b);
    for(int i=a.size()-1,j=b.size()-1;i>=0;i--,j--){
      if(j >= 0) a[i] += b[j]-'0';
      if(a[i] > '9'){
	a[i] -= 10;
	if(i == 0) a = "1" + a;
	else a[i-1]++;
      }
    }
    if(a.size() > 80) cout << "overflow" << endl;
    else cout << a << endl;
  }
}

Measured memory_bytes: 1212
N,M = list(map(int,input().split()))
H = list(map(int,input().split()))
A = [[] for i in range(N)]
for i in range(M):
    a,b = list(map(int,input().split()))
    A[a-1].append(H[b-1])
    A[b-1].append(H[a-1])
ttl = 0
for i in range(N):
    ans = 0
    if len(A[i]) == 0:
        ttl += 1
    else:
        for j in A[i]:
            if j >= H[i]:
                ans += 1
        if ans == 0:
            ttl += 1
print(ttl)

Measured memory_bytes: 92228
def main():
  while True:
    INF = 10 ** 10
    s, d, m = map(int, input().split())
    ws = []
    ps = []
    for _ in range(s):
      input()
      wplst = list(map(int, input().split()))
      ws.append(wplst[::2])
      ps.append(wplst[1::2])
    fs = list(map(int, input().split()))
    wlst = []
    plst = []
    for f in fs:
      wlst += ws[f]
      plst += ps[f]
  
    dp = [-INF] * (m + 1)
    dp[0] = 0
    for w, p in zip(wlst, plst):
      for i in range(m - p, -1, -1):
        if dp[i + p] < dp[i] + w:
          dp[i + p] = dp[i] + w
  
    max_score = max(dp)
    print(max_score, dp.index(max_score))
    
    try:
      input()
    except EOFError:
      break

main()


Measured memory_bytes: 5776
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    char c;
    cin >> c;
    cout << char(c+1) << endl;
    return 0;
}

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

#input
N, M, C = map(int, raw_input().split())

Blist = [map(int, raw_input().split())]
Alist = [map(int, raw_input().split()) for i in range(0, N)]

#print(Blist)
#print(Alist)

count = 0

for x in range(N):
    AB = [x * y for (x, y) in zip(Blist[0], Alist[x])]
    #print(AB)
    ans = sum(AB) + C
    #print(ans)
    if ans > 0:
        count += 1

print(count)


Measured memory_bytes: 2568
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}
	
int main()
{      
  LL a,b,c,d;
  cin>>a>>b>>c>>d;
  
  a--;
  LL tem=(c*d)/__gcd(c,d);
  LL ans=b/c+b/d-b/tem;
  ans-=a/c+a/d-a/tem;
  
  cout<<b-a-ans<<endl;

  
  return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  Testcpp
//
//  Created by sandeep.m on 07/07/17.
//  Copyright © 2017 sandeep.m. All rights reserved.
//


#include <cstdio>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <bitset>
#include <utility>
#include <ctime>
#include <cassert>
#include <climits>

using namespace std;

int main(int argc, const char * argv[]) {
    int n; cin >> n;
    int ox; cin >> ox;
    int oy; cin >> oy;
    int an = -1, an1;
    for(int i = 0; i < n; i++)  {
        an1 = an;
        cin >> an;
    }
    int ans = abs(an - oy);
    if(n > 1)   {
        ans = max(ans, abs(an - an1));
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  int A, B; std::cin >> A >> B;
  int K = A + (B-A)/2;
  if(K - A == B - K) fin(K);
  fin("IMPOSSIBLE");
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int n = sc.nextInt(), m = sc.nextInt();
                        int[][] a = new int[n][m];
                        for (int i = 0; i < n; i++) {
                                for (int j = 0; j < m; j++) {
                                        a[i][j] = sc.nextInt();
                                }
                        }
                        int[] x = new int[m];
                        for (int i = 0; i < m; i++) {
                                x[i] = sc.nextInt();
                        }
                        for (int i = 0; i < n; i++) {
                                int ans = 0;
                                for (int j = 0; j < m; j++) {
                                        ans += x[j] * a[i][j];
                                }
                                System.out.println(ans);
                        }
                }
        }
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int INF = 1000000007;
    int N;
    cin >> N;
    vector<int> dp(100100, INF);
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        dp[i + 1] = min(dp[i] + 1, dp[i + 1]);
        int tmp = 6;
        while (tmp + i <= N) {
            dp[tmp + i] = min(dp[i] + 1, dp[tmp + i]);
            tmp *= 6;
        }
        tmp = 9;
        while (tmp + i <= N) {
            dp[tmp + i] = min(dp[i] + 1, dp[tmp + i]);
            tmp *= 9;
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

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

const ll MODULO = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  vll c, w;
  int curColor = -1;
  int curW = 0;
  for (int i = 0; i < n; ++i) {
    int color;
    cin >> color;
    if (color == curColor) {
      //curW++;
      continue;
    }
    if (curW > 0) {
      c.push_back(curColor);
      w.push_back(curW);
    }
    curColor = color;
    curW = 1;
  }
  if (curW > 0) {
    c.push_back(curColor);
    w.push_back(curW);
  }
  n = c.size();
  vi last(3e5, n);
  vll a(n + 1);
  vll sum(n + 1);
  a[n] = 1;
  for (int i = n - 1; i >= 0; --i) {
    if (last[c[i]] < n) sum[i] = (sum[last[c[i]]] + w[last[c[i]]] * a[last[c[i]] + 1]) % MODULO;
    a[i] = (a[i + 1] + w[i] * sum[i]) % MODULO;
    last[c[i]] = i;
  }

  cout << a[0] << endl;

  return 0;
}


Measured memory_bytes: 7908
N, T = map(int, input().split())

min_cost = 100000000

for i in range(N):
  cost, time = map(int, input().split())
  if time <= T and cost < min_cost:
    min_cost = cost
    
if min_cost is 100000000:
  print('TLE')
else:
  print(min_cost)

Measured memory_bytes: 2940
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>
#include <iomanip>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main() {
	int N = 50001;
	vi p(N, 1);
	p[0] = p[1] = 0;
	rep (i, N) if (p[i]) for(int j = i + i; j < N; j += i) p[j] = 0;
	vi ps;
	rep(i, N) if (p[i]) ps.pb(i);
	for (int n; cin >> n, n != 0; ) {
		int cnt = 0;
		for(int i = 0; ps[i] <= n / 2; i++) {
			int b = n - ps[i];
			if (p[b]) cnt++;
		}
		cout << cnt << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <iomanip>
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define SORT(s) sort((s).begin(),(s).end())

ll f(ll n,ll x) {
    return n/x;
}

int main(){
    ll a,b,x; cin >> a  >> b >> x;
    if(a==0){
        cout << f(b,x) + 1 << endl;
    }else{
       cout << f(b,x) - f(a-1,x) << endl;
    }
}




Measured memory_bytes: 3604
from itertools import permutations
from math import sqrt, factorial
n = int(input())
lst = [None]

for _ in range(n):
    x,y = map(int,input().split())
    lst.append([x,y])

ans = 0

for per in permutations(list(range(1,n+1))):
    lenth = 0
    for i in range(0,n-1):
        x1,y1 = lst[per[i]]
        x2,y2 = lst[per[i+1]]
        lenth += sqrt((x2-x1)**2 + (y2-y1)**2)
    ans += lenth

ans /= factorial(n)

print(ans)


Measured memory_bytes: 73960
#include<stdio.h>
int main()
{
    int n,i,j,k;
    long int sum=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                sum+=gcd(i,j,k);
            }
        }
    }
    printf("%ld",sum);
}
int gcd(int a,int b,int c)
{
    int st,m;
    st=a<b?(a<c?a:c):(b<c?b:c);
    for(m=st;m>=1;m--)
    {
        if(a%m==0 && b%m==0 && c%m==0)
        {
            return(m);
        }
    }
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }







void solve() {
    string n;
    cin>>n;
    bool ok = false;
    rep(i,3) if(n[i]=='7') ok = true;
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    
}


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


    ll t=1;
    
    // cin>>t;

    rep(i,t){
        solve(); 
    }

    return 0;
}


Measured memory_bytes: 3624
K = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

a = input()
a = int(a)
print(K[a-1])

Measured memory_bytes: 3064
# coding: utf-8

H = int(input())
W = int(input())
N = int(input())

cnt = 0
painted = 0

while painted < N:
    if H < W:
        painted += W
        cnt += 1
        H -= 1
    else:
        painted += H
        cnt += 1
        W -= 1

print(cnt)

Measured memory_bytes: 3060
#include<math.h>
#include<time.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
int main()
{
	int a,b,c,t;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b)
	{
		t=a;
		a=b;
		b=t;
	}
	if(b>c)
	{
		t=b;
		b=c;
		c=t;
	}
	if(a>b)
	{
		t=a;
		a=b;
		b=t;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}


Measured memory_bytes: 2060
import sys
from collections import defaultdict
from queue import deque
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    N = gete(int)
    c = list(geta(int))
    c.sort(key=lambda x: -x)
    mod = 10**9 + 7
    dp = [0] * (N + 1)

    base = 1
    for n in range(1, N + 1):
        dp[n] = 4 * dp[n - 1] + (n + 1) * base * c[n - 1]
        base *= 4

        dp[n] %= mod
        base %= mod
    print(dp[N])


if __name__ == "__main__":
    main()

Measured memory_bytes: 88616
from bisect import bisect_right
N = int(input())
W = list(map(int, input().split()))
s=[0]*(N+1)
for i in range(N):
  s[i+1] = s[i] + W[i]
result = s[N-1]
for i in range(N):
  s1 = s[i]
  s2 = s[N] - s1
  result = min(result, abs(s2-s1))
print(result)

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	m := make(map[string]int)
	for i := 0; i < N; i++ {
		var s string
		fmt.Scan(&s)
		m[s]++
	}
	if len(m) == 4 {
		fmt.Println("Four")
	} else {
		fmt.Println("Three")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

ll l[201][201];
ll s[201][201];
ll dp[1001][201];


int main(){
	int n,m,r;
	while(cin >> n >> m && n!=0){
		for(int i=0;i<200;i++){
			for(int j=0;j<200;j++){
				l[i][j] = inf;
				s[i][j] = inf;
				if(i==j){
					l[i][j] = 0;
					s[i][j] = 0;
				}
			}
		}
		for(int i=0;i<m;i++){
			int x,y;
			ll t;
			char c;
			cin >> x >> y >> t >> c;
			x--;
			y--;
			if(c=='L'){
				l[x][y] = min(l[x][y],t);
				l[y][x] = min(l[x][y],t);
			}else{
				s[x][y] = min(s[x][y],t);
				s[y][x] = min(s[x][y],t);
			}
		}
		for(int k=0;k<n;k++){
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					l[i][j] = min(l[i][k]+l[k][j],l[i][j]);
					s[i][j] = min(s[i][k]+s[k][j],s[i][j]);
				}
			}
		}
		cin >> r;
		vector<int> z(r);
		for(int i=0;i<r;i++){
			cin >> z[i];
			z[i]--;
		}
		for(int i=0;i<r;i++){
			for(int j=0;j<n;j++){
				dp[i][j] = inf;
			}
		}
		dp[0][z[0]] = 0;
		for(int i=1;i<r;i++){
			for(int j=0;j<n;j++){
				for(int k=0;k<n;k++){
					if(j==k) dp[i][j] = min(dp[i][j],dp[i-1][k] + l[z[i-1]][z[i]]);
					else dp[i][j] = min(dp[i][j],dp[i-1][k]+l[z[i-1]][k]+s[k][j]+l[j][z[i]]);
				}
			}
		}
		ll ans = inf;
		for(int i=0;i<n;i++){
			ans = min(ans,dp[r-1][i]);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 5260
package main

import (
	"fmt"
	"math"
)

func main() {
	var x int
	fmt.Scan(&x)
	r := 0

	for i := 1; i <= x; i++ {
		for p := 2; p <= 10; p++ {
			t_r := math.Pow(float64(i), float64(p))
			if int(t_r) <= x && int(t_r) > r {
				r = int(t_r)
			}
		}
	}
	fmt.Println(r)
}


Measured memory_bytes: 512
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = ToIntArray(input.ReadLine(), n);

        Array.Sort(ary, (x,y)=>y-x);

        var ali = 0;
        var bob = 0;
        for(int i=0; i<n; i++) {
            if (i % 2 == 0) ali += ary[i];
            else bob += ary[i];
        }

        return ali - bob;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define si(x) scanf("%d",&x)
#define pi(x) printf("%d\n",x)
#define s(x) scanf("%I64d",&x)
#define p(x) printf("%I64d\n",x)
#define sc(x) scanf("%s",x)
#define pc(x) printf("%s",x)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define M 1000000007
#define N 1000002
#define inf 1e15
#define PQG priority_queue< int,std::vector<int>,std::greater<int> >
#define PQL priority_queue< int,std::vector<int>,std::less<int> >
#define PQPL priority_queue<pii ,vector< pii >, less< pii > >
#define PQPG priority_queue<pii ,vector< pii >, greater< pii > >
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

using namespace std;


int main() {
    fast_io;
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) cout<<"YES\n";
    else cout<<"NO\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //
        //Euclid e1=new Euclid();//ユークリッドの互除法
        //Compute c1=new Compute();//累積和，
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        double answer = 0;
        //String answer="Yes";
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];
        
        //入力
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        answer=(double)W*H/2;
        int num;
        if(W==x*2 && H==y*2) {num=1;}
        else {num=0;}
        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        //System.out.println(answer);
        System.out.println(String.format("%.10f",answer)+" "+num);
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 151, task C, 2020/06/25
//ms,
/*
*/

int main(void){
  int N, M;
  int tmp_p;
  string tmp_S;
  vector<int> task_status(100000);
  /*
  ACed: -1
  else: more than 0, means how many WA
  */
  int ac_num=0;
  int pen_num=0;

  cin >>N >>M;
  for(int i=0;i<N;i++){task_status[i]=0;}

  for(int i=0;i<M;i++){
    cin >>tmp_p >>tmp_S;
    if(task_status[tmp_p-1]==-1) continue;

    if(tmp_S == "AC"){
      pen_num += task_status[tmp_p-1];
      task_status[tmp_p-1] = -1;
      ac_num++;
    }else task_status[tmp_p-1]++;
  }
  cout <<ac_num <<" " <<pen_num <<endl;

  return 0;
}
/*
*/


Measured memory_bytes: 3720