akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
from collections import defaultdict

N, M = map(int, stdin.readline().split())

WAinProblem=defaultdict(int)#defaultdictは初期値が0(int)なdict
totalWA=0
totalAC=0
for _ in range(M):
  line=stdin.readline().split()
  problem_number=int(line[0])
  result=line[1]

  if result == "WA":
    if WAinProblem[problem_number]!=-1:#集計終了していなければ
      WAinProblem[problem_number]+=1
  else:#result="AC"
    if WAinProblem[problem_number]!=-1:#集計終了していなければ
      totalWA+=WAinProblem[problem_number]
      totalAC += 1
      WAinProblem[problem_number]=-1#集計終了
print("{} {}".format(totalAC,totalWA))

Measured memory_bytes: 15460
#include <bits/stdc++.h>
using namespace std;
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
//##define FOR(k) "int i=0;i<k;i++"
//特定文字の個数を数える
int search(string s){
	int n=s.size();
	int num = 0;

	for(int i=0;i<n;i++){
		if(s[i] == '1'){
			num++;
		}
	}
	return num;
}

int main(){
    int a,b,c;
    string ans="No";
    cin >> a>>b>>c;
    if(MIN(a,c)==c&&MAX(b,c)==c) ans = "Yes";
    else if (MIN(b,c)==c&&MAX(a,c)==c) ans = "Yes";
    else ans = "No";
    
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n;
long long ans;
int main(){
	cin>>n;
	for(int i=0;i<=n;i++){
		if(i%3==0 || i%5==0){
			continue;
		}else{
			ans+=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3628
#define loop(i, s, e) for(ll i = s;i < e;i++)

#include <iostream>
#include <iomanip>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;
//using namespace libcgl;
typedef long long signed ll;

ll n, k;

/*

int main() {
    cin >> n >> k;
    ll res = 0;
    loop(kk,0,k){
        if((kk * 2) % k == 0) {
            ll c = (n - kk) / k;
            if(kk != 0) c++;
            if(c > 0) res += c * c * c;
        }
    }
    cout << res << endl;
}

*/

ll l;

class graph {
public:
    class path {
    public:
        int len,from,to;
        path(int len_,int from_,int to_) {
            len = len_;from = from_;to = to_;
        }
    };
    int nodes;
    vector<path> paths;
};

graph makeGraph(int maxDist) {
    if(maxDist == 0) {
        graph t;
        t.nodes = 1;
        return t;
    }
    if(maxDist == 1) {
        graph t;
        t.nodes = 2;
        t.paths.push_back(graph::path(0,0,1));
        t.paths.push_back(graph::path(1,0,1));
        return t;
    }
    if(maxDist == 2) {
        graph t;
        t.nodes = 2;
        t.paths.push_back(graph::path(0,0,1));
        t.paths.push_back(graph::path(1,0,1));
        t.paths.push_back(graph::path(2,0,1));
        return t;
    }
    int cdst = (maxDist-1) / 2;
    auto g = makeGraph(cdst);
    g.paths.push_back(graph::path(0,g.nodes-1,g.nodes));
    g.paths.push_back(graph::path(cdst+1,g.nodes-1,g.nodes));
    if(maxDist % 2 == 0)
        g.paths.push_back(graph::path(maxDist,0,g.nodes));
    g.nodes++;
    return g;
}

int main() {
    cin >> l;
    auto g = makeGraph(l-1);
    cout << g.nodes << " " << g.paths.size() << endl;
    for(auto e:g.paths) {
        cout << e.from + 1 << " " << e.to + 1 << " " << e.len << endl;
    }
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
L = [LIST() for i in range(M)]
P = LIST()

import itertools
#L = [0, 1] #生成する数字
num = N #生成するビット数
bit_list = list(itertools.product([0, 1], repeat=num))
#print(bit_list)
ans = 0
#print(L[0][0])
on = 0
for bit in bit_list:
    # ココ注意
    cnt = 0
    for i in range(M):
        #print(L[i][1:])
        wa = 0
        on = 0
        for s in L[i][1:]:
            on += bit[s-1]
        # wa == P[i]なら，その電球は点灯する
        if P[i] == on % 2:
            cnt += 1
        #if cnt == L[i][0]:
        #    c += 1
    if cnt == M:
        ans += 1
print(ans)



Measured memory_bytes: 5844
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include<iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;

vector<vector<int>>edge;
vector<int> x;
typedef pair<int,int> P;
bool ok =1;
P dfs(int node)
{
  if(edge[node].empty())return make_pair(0,x[node]);
  vector<vector<bool>>dp(2,vector<bool>(x[node]+1,0));
  dp[0][0]=1;
  int sz=edge[node].size();
  int cnt=0;
  rep(i,sz)
  {
    int ne=(i+1)&1,no=i&1;
    P tp=dfs(edge[node][i]);
    if(tp.first==-1)return make_pair(-1,-1);
    cnt+=tp.first+tp.second;
    rep(j,x[node]+1)dp[ne][j]=0;
    rep(j,x[node]+1)
    {
      if(tp.first+j<x[node]+1) dp[ne][j+tp.first] = dp[ne][j+tp.first] |dp[no][j];
      if(tp.second+j<x[node]+1) dp[ne][j+tp.second] = dp[ne][j+tp.second] |dp[no][j];

    }
  }
  for(int i=x[node];i>=0;i--)
  {
    if(dp[sz&1][i])
    {
      int a=cnt-i,b=x[node];
      if(a>b)swap(a,b);
      //cout<<"dfs"<<a<<" "<<b<<endl;
      //cout<<cnt<<" "<<i<<endl;
      return make_pair(a,b);
    }
  }
  ok=0;
  return make_pair(-1,-1);
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int n;
  cin>>n;
  edge.resize(n+1);
  x.resize(n+1);
  rep(i,n-1)
  {
    int pare;
    cin>>pare;
    edge[pare].push_back(i+2);
  }
  rep(i,n)cin>>x[i+1];
  dfs(1);
  cout<<(ok? "POSSIBLE":"IMPOSSIBLE")<<endl;
  return 0;

}


Measured memory_bytes: 768
#include<cstdio>
#include<algorithm>
using namespace std;
long long n, plus, minus;
long long a[200010], b[200010];

int main()
{
    // 正の数と負の数がトントンになるタイミングをはかる
    plus = 0;
    minus = 0;

    scanf("%lld", &n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%lld", &a[i]);
        b[i] = a[i] - i;
    }

    sort(b, b+n);
    long long cen = b[n/2];

    long long ans = 0;
    for (int i = 0; i < n; ++i)
    {
        ans += abs(b[i] - cen);
    }

    printf("%lld\n", ans);
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	int n;
	cin >> n;
	vi a(n);
	rep(i,n) cin >> a[i];
	sort(all(a));
	int flag = 1;
	for(int i = 1; i < n; i++){
		if(a[i-1] == a[i]) flag = 0;
	}
	cout << (flag ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fst first
#define snd second
#define mp make_pair
using namespace std;

typedef long long ll;

const int maxn=3e3+10;

const ll inf=1e18+10;

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

ll dp[maxn][maxn][4],n,m,k;
ll cost[maxn][maxn];
priority_queue <pair<ll,pair<pair<int,int>,int> > > que;

bool check(int x,int y){
	if(x>=n||y>=m) return false;
	return true;
}

int main(){
	for(int i=0;i<maxn;i++) for(int j=0;j<maxn;j++) for(int c=0;c<4;c++) 
		dp[i][j][k]=-inf;
	cin>>n>>m>>k;
	for(int i=0;i<k;i++){
		int x,y;
		cin>>x>>y;
		x--; y--;
		cin>>cost[x][y];
	}
	dp[0][0][0]=0;
	dp[0][0][1]=cost[0][0];
	for(int x=0;x<n;x++) for(int y=0;y<m;y++) for(int c=0;c<4;c++){
		for(int d=0;d<2;d++){
			int nx=x+dx[d],ny=y+dy[d];
			dp[nx][ny][c]=max(dp[x][y][c],dp[nx][ny][c]);
			if(nx==x+1) dp[nx][ny][0]=max(dp[nx][ny][0],dp[x][y][c]);
			if(c+1<=3) dp[nx][ny][c+1]=max(dp[nx][ny][c+1],dp[x][y][c]+cost[nx][ny]);
			if(nx==x+1) dp[nx][ny][1]=max(dp[x][y][c]+cost[nx][ny],dp[nx][ny][1]);
		}
	}
	ll ans=0;
	for(int i=0;i<=3;i++) ans=max(ans,dp[n-1][m-1][i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 357092
main :: IO ()
main = do
    n <- (map read) . words <$> getLine
    a <- (map read) . words <$> getLine
    putStrLn $ show $ solve n a

solve :: [Int] -> [Int] -> Int
solve n a =
    let m = n !! 1
        x = n !! 2
        l = length $ filter (\b -> b < x) a
    in min l (m - l)

Measured memory_bytes: 892
from sys import stdin
import numpy as np
n, k = map(int, stdin.readline().split())
a = np.array(stdin.readline().split(), dtype=np.int64)

ng = 0
ok = 10 ** 9 + 1
while ok - ng > 1:
    mid = (ok + ng) >> 1
    if np.sum(np.ceil(a / mid) - 1) <= k:
        ok = mid
    else:
        ng = mid
print(ok)


Measured memory_bytes: 52636
#include <cassert>
#include <cmath>
#include <cstdio>
#define SIZE 244140625

int Hash(const char* Text)
{
    int Hash = 0;
    for(const char* c  = Text; *c; ++c){
        if(c != Text){
            Hash *= 5;
        }
        switch(*c){
        case 'A':
            Hash += 1; break;
        case 'C':
            Hash += 2; break;
        case 'G':
            Hash += 3; break;
        case 'T':
            Hash += 4; break;
        default:
            assert(false);
        }
    }
    return Hash;
}
int main()
{
    bool* dic = new bool[SIZE];
    int n;
    std::scanf("%d", &n);
    char command[7];
    char str[13];
    for(int i = 0; i < n; ++i){
        std::scanf("%s %s", command, str);
        if(command[0] == 'i'){
            dic[Hash(str)] = true;
        }else
        if(command[0] == 'f'){
            std::puts((dic[Hash(str)] ? "yes" : "no"));
        }
    }
    return 0;
 }

Measured memory_bytes: 11384
cards = [[False for i in range(13)] for j in range(4)]

pattern = ["S", "H", "C", "D"]
z = int(input())

for a in range(z):
    x, y = input().split()
    y = int(y)
    if x == "S":
        cards[0][y-1] = True
    elif x == "H":
        cards[1][y-1] = True
    elif x == "C":
        cards[2][y-1] = True
    elif x == "D":
        cards[3][y-1] = True

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



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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

int h, w, d;
char s[4] = { 'R', 'Y', 'G', 'B' };

int main() {
	read(h), read(w), read(d);
	for (int i = 1; i <= h; ++i, putchar('\n'))
		for (int j = 1; j <= w; ++j) {
			int x = i + j, y = i - j;
			putchar(s[(((x + w) / d) & 1) * 2 + (((y + w) / d) & 1)]);
		}
	return 0;
}

Measured memory_bytes: 512
def main():
    n = input().split()
    a = int(n[0])
    b = int(n[1])

    if a <= 0 or a >= 101 or b <= 0 or b >= 101:
        print("invalid answer.")
        return

    ans1 = a*b
    ans2 = (a+b)*2

    print("{0} {1}".format(ans1,ans2))

if __name__ == '__main__':
    main()

Measured memory_bytes: 5596
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int main() {
	for(int n; cin >> n&&n;){
		int s = 0;	s -= n;
		for (int i = 1; i <= sqrt(n); i++) {
			if (n%i == 0) {
				s += n / i;
				if (n != 1 && i != n / i) s += i;
			}
		}

		if (n == s)
			cout << "perfect number" << endl;
		else if (n > s)
			cout << "deficient number" << endl;
		else
			cout << "abundant number" << endl;

	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <string>

int main() {
  int N;
  std::cin >> N;

  std::vector<int> data(N);
  for(int i = 0; i < N; ++i) {
    std::cin >> data[i];
  }

  for(int i = 0; i < data.size(); ++i){
    auto key = data[i];
    auto j = i - 1;
    while( j >= 0 && data[j] > key ) {
      data[j + 1] = data[j];
      --j;
    }
    data[j + 1] = key;

    
    for( int i = 0; i < data.size() - 1; ++i )
      std::cout << data[i] << " ";
    if ( !data.empty() )
      std::cout << data.back();
    std::cout << std::endl;
  }

  return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

ll N,W;
ll w[100010];
ll v[100010];
ll dp[100010];

int main ()
{
    cin >> N >> W;
    REP(i,N) cin >> w[i] >> v[i];
    REP(i,100010) dp[i] = 1e18;
    dp[0] = 0;

    for (int i = 0; i < N; i++) {
        for (int j = 100005; j >= 0; j--) {
            if (j + v[i] > 100005) continue;
            dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
        }
    }

    ll ans = 0;
    REP(i,100005) {
        if (dp[i] <= W) 
        ans = max(ans, (ll)i);
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

bool cond1(string line) {
  int n = line.size();
  for (int i = 0; i < (n - 1) / 2; i++) {
    if (line[i] != line[n - i - 1]) return false;
  }
  return true;
}

bool cond2(string line) {
  int n = line.size();
  int h = (n - 1) / 2;
  for (int i = 0; i < h / 2; i++) {
    if (line[i] != line[h - i - 1]) return false;
  }
  return true;
}

bool cond3(string line) {
  int n = line.size();
  int h = (n - 1) / 2;
  for (int i = 0; i < h / 2; i++) {
    if (line[n - i - 1] != line[h + 1 + i]) return false;
  }
  return true;
}

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

  int n = line.size();
  if (cond1(line) && cond2(line) && cond3(line))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
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;
}
int main(){
    ll a,b,n;cin>>a>>b>>n;
    ll x;
    if(b-1<=n)x=b-1;
    else x=n;
    ll ans=(a*x)/b-a*(x/b);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3572
readD :: String -> Double
readD = read

main = do
    s <- words<$>getContents
    print $ solve s

solve :: [String] -> Double
solve (n:s) = compute s

compute [] = 0
compute (a:x:s) = convert [a,x] + compute s

convert [a,x] = if x == "BTC" then b*380000 else b
 where
  b = readD a

Measured memory_bytes: 636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;

class MainClass
{
    static void Main()
    {
        var NX = Console.ReadLine().Split().Select(long.Parse).ToArray();
        int N = (int)NX[0];
        long X = NX[1];

        var leng = new long[N + 1];leng[0] = 1;
        var patty = new long[N + 1];patty[0] = 1;
        for(int i = 0; i < N; i++)
        {
            leng[i + 1] = leng[i] * 2 + 3;
            patty[i + 1] = patty[i] * 2 + 1;
        }

        int n = N;
        long ans = 0;
        while (n >= 0)
        {
            if (X < leng[n] / 2)
            {
                X = X == 0 ? 0 : --X;
                n--;
            }
            else if (X == leng[n] / 2)
            {
                ans += patty[n] / 2;
                break;
            }
            else
            {
                ans += patty[n] / 2 + 1;
                X -= leng[n] / 2 + 1;
                n--;
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 28228
N = int(input())
A = [int(x) for x in input().split()]

cnt = [0 for _ in range(10**5 + 5)]
for a in A:
    cnt[a] += 1

ans = sum(A)

Q = int(input())

for _ in range(Q):
    B, C = map(int, input().split())

    ans -= B * cnt[B]
    ans += C * cnt[B]

    cnt[C] += cnt[B]
    cnt[B] = 0

    print(ans)


Measured memory_bytes: 20608
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll a, b;
    cin >> a >> b;

    ll ans = 0;
    ll aki = 1;
    
    while (b > aki) {
        aki--;
        aki += a;
        ans++;
    }
    cout << ans << endl;
}

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

int main(){
    ll N; cin >> N;
    if(N%2==1){
        cout << 0;
        return 0;
    }
    
    
    ll ans=0;
    for (ll i=10; i<=N; i*=5){
        ans+=N/i;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <ctype.h>
 
using namespace std;
int main() {
	string S;
	int f=0;
	while(cin>>S){
		if(f++){cout<<" ";}
 
		for(int i=0; i<S.size(); i++){
			if(S[i]>='A' && S[i]<='Z'){
				S[i]=tolower(S[i]);
			}else if(S[i]>='a' && S[i]<='z'){
				S[i]=toupper(S[i]);
			}
		}
		cout<<S;
	}
	cout<<endl;
	return 0;
}

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

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

  int res = 0;
  for (int l = 0; l <= min(n,k); l++) {
    for (int r = 0; l + r <= min(n,k); r++) {
      int tmp = 0;
      vector<int> have;
      for (int i = 0; i < l; i++) tmp += v[i], have.push_back(v[i]);
      for (int i = n - 1; i > n - r - 1; i--) tmp += v[i], have.push_back(v[i]);
      
      sort(have.begin(), have.end());
      for (int i = 0; i < min(k-r-l, sz(have)); i++) {
        if (have[i] < 0) tmp -= have[i];
      }
      res = max(res,tmp);
    }
  }
  cout << res << endl;
  return 0;
} 

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

using namespace std;

int main(){
    int n, m, c; cin >> n >> m >> c;
    vector<int> bs(m);
    for(int i=0; i<m; ++i){
        cin >> bs[i];
    }
    int ans=0;
    for(int i=0; i<n; ++i){
        int e=c;
        for(int j=0; j<m; ++j){
            int a; cin >> a;
            e+=a*bs[j];
        }
        if(e>0) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;

class Main {

    static Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws Exception {

       char c = sc.next().charAt(0);
       if(Character.isUpperCase(c))
        out.println("A");
        else out.println("a");

        out.flush();
        out.close();
        sc.close();
    }

    static final int MOD = (int) 1e9 + 7;
    static final double PI = 3.14159265358979323846;

    // takes array input
    public static int[] init(int n) {

        int[] arr = new int[n];

        for (int i = 0; i < n; ++i)
            arr[i] = sc.nextInt();

        return arr;
    }

    // finds GCD of two number
    public static int gcd(int a, int b) {

        if (a == 0) {
            return b;
        }

        return gcd(b % a, a);
    }

    // checks whether a number is prime or not
    public static boolean prime(int n) {

        if (n < 2)
            return false;

        for (int i = 2; i * i <= n; ++i)
            if (n % i == 0)
                return false;

        return true;
    }
}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a.at(i);
  ll res = 0;
  for (int i = 1; i < n; ++i) {
    if (a.at(i-1) > a.at(i)) {
      ll dif = a.at(i-1) - a.at(i);
      a.at(i) = a.at(i-1);
      res += dif;
    }
  }
  cout << res << endl;
  return 0;
}


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

int main() {
  int n;
  cin>>n;
  int s1 = n/100;
  int s2 = n%100;
  bool m1=0,m2=0;
  if(s1<=12&&s1>=1) m1=true;
  if(s2<=12&&s2>=1) m2=true;

  if(m1&&m2) cout<<"AMBIGUOUS"<<endl;
  else if(m1==1 && m2==0) cout<<"MMYY"<<endl;
  else if(m1==0 && m2==1) cout<<"YYMM"<<endl;
  else cout<<"NA"<<endl;

}


Measured memory_bytes: 768
fn main() {
    let scan = std::io::stdin();
    
    let mut line = String::new();
    
    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();
    
    let a: f64 = vec[0].parse().unwrap_or(0.0);
    let b: f64 = vec[1].parse().unwrap_or(0.0);
    let c: f64 = vec[2].parse().unwrap_or(0.0);

    let s: f64 = a * b * 0.5 * (2.0 * c  * std::f64::consts::PI / 360 as f64).sin();
    let l: f64 = a + b + (a * a + b * b - 2 as f64 * a * b * (2.0 * c * std::f64::consts::PI / 360 as f64).cos()).powf(0.5);
    let h: f64 = 2 as f64 * s / a;
    println!("{:.6}", s);
    println!("{:.6}", l);
    println!("{:.6}", h);
}



Measured memory_bytes: 5192
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a = [2,4,5,7,9]
b = [0,1,6,8]

n = ns()
m = int(n[-1])

if m in a:
    print('hon')
elif m in b:
    print('pon')
else:
    print('bon')

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    ll h;
    cin >> h;
    ll ans = 0;
    ll p = 1;
    do
    {
        ans += p;
        p *= 2;
        h /= 2;

    } while (h > 0);
    c(ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int T = sc.nextInt();
		
		Double td = new Double(T + ".5");
		Double ad = new Double(A + "");
		Double atd = td/ad;
		int ati = atd.intValue();
		int result = ati*B;
		System.out.println(result);
	}

}


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

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main(){
    int N;
    string s;
    cin >> N >> s;
    int q = 0;
    int e = 0;
    rep(i,N){
        if (s[i] == 'W'){
            q++;
        }
    }
    //cout << q;
    rep(i,N-q){
        if(s[i] == 'W'){
            e++;
        }
    }
    cout << e;
    return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の string型配列と同じような感じ）
map<int, string> mp;
for (auto itr =mp.begin(); itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;

//pair
//たくさんつくる
vector<pair<int,string>> hoge(10);
//参照
hoge[0].first
sort(all(hoge), greater<pair<int, string>>());




*/


Measured memory_bytes: 3756
#include <stdio.h>
int main(void){

    int c[3][3];
    for(int i=0;i<3;++i){
        for(int l=0;l<3;++l){
            int a;
            scanf("%d",&a);
            c[i][l] = a;
        }
    }
    if(c[0][0] + c[1][1] ==  c[0][1] + c[1][0]){
        if(c[1][0] + c[2][1] ==  c[2][0] + c[1][1]){
            if(c[0][1] + c[1][2] ==  c[0][2] + c[1][1]){
                if(c[1][1] + c[2][2] ==  c[1][2] + c[2][1]){
                    printf("Yes");
                    return 0;
                }
            }
        }
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <list>
using namespace std;
int main()
{
  int n,i,l;
  string s;
  list<char> ls;
  list<char>::iterator is,ie;
  cin >> n;
  while(n--){
    ls.clear();
    cin >> s;
    ls.push_back(s[0]);
    l = s.length();
    is = ie = ls.begin();
    for(i=1; i<l; i+=3){
      string t = s.substr(i,2);
      if(t == "->" && *ie == s[i-1]){
	ls.push_back(s[i+2]);
	ie = ls.end();
	ie--;
      }else if(t == "<-" && *is == s[i-1]){
	ls.push_front(s[i+2]);
	is = ls.begin();
      };
    }
    is = ls.begin();
    while(is != ls.end()){
      cout << *is;
      is++;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

// merge sort

int cnt = 0;

void merge(vector<int>& a, int left, int mid, int right) {
  // cout << left << " " << mid << " " << right << endl;
  constexpr int inf = numeric_limits<int>::max();
  int n1 = mid - left;
  int n2 = right - mid;
  vector<int> L(n1+1), R(n2+1);
  for (int i = 0; i < n1; ++i) {
    L.at(i) = a.at(left+i);
  }
  for (int i = 0; i < n2; ++i) {
    R.at(i) = a.at(mid+i);
  }
  L.at(n1) = inf;
  R.at(n2) = inf;
  int i = 0, j = 0;
  for (int k = left; k < right; ++k) {
      cnt += 1;
    if (L[i] <= R[j]) {
      a[k] = L[i++];
    } else {
      a[k] = R[j++];
    }
  }
}

void mergeSort(vector<int>& a, int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(a, left, mid);
    mergeSort(a, mid, right);
    merge(a, left, mid, right);
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);

  rep(i, n) cin >> a[i];

  mergeSort(a, 0, n);
  
  for (int i = 0; i < n; ++i) {
    if (i == n-1) cout << a[i];
    else cout << a[i] << " ";
  }
  
  cout << "\n" << cnt << endl;
}



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

const long long INF = 9e18;
const int N = 1e5 + 10;

long long sum[N], a[N];
int x[N], y[N];
int n;
set<int> G[N];
pair<int, int> pX[N];
pair<int, int> pY[N];

struct edge {
    int a, b;
    int cost;
    bool operator < (struct edge e) const {
        return cost < e.cost;
    }
}e[N * 4];

int len;

int fa[N];

int find(int u) {
    if (fa[u] != u) return fa[u] = find(fa[u]);
    return fa[u];
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        fa[i] = i;
        cin >> x[i] >> y[i];
        pX[i] = {x[i], i};
        pY[i] = {y[i], i};
    }
    sort(pX + 1, pX + 1 + n);
    sort(pY + 1, pY + 1 + n);
    for (int i = 1; i <= n; i++) {
        if (i + 1 <= n) G[pX[i].second].insert(pX[i + 1].second);
        if (i - 1 > 0) G[pX[i].second].insert(pX[i - 1].second);
    }
    for (int i = 1; i <= n; i++) {
        if (i + 1 <= n) G[pY[i].second].insert(pY[i + 1].second);
        if (i - 1 > 0) G[pY[i].second].insert(pY[i - 1].second);
    }
    for (int i = 1; i <= n; i++) {
        for (int t : G[i]) {
            e[len++] = {i, t, min(abs(x[i] - x[t]), abs(y[i] - y[t]))};
        }
    }
    sort(e, e + len);
    int cnt = 0;
    long long ans = 0;
    for (int i = 0; i < len; i++) {
        int u = find(e[i].a);
        int v = find(e[i].b);
        if (u != v) {
            cnt += 1;
            ans += e[i].cost;
            fa[u] = v;
        }
        if (cnt == n - 1) break;
    }
    cout << ans << endl;
    return 0;
}


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

choku = []
lst=[]
for i in range(n):
    l= [int(x) for x in list(str(n))]
    x = sum(l)
    if x >= a and x <= b:
        choku.append(n)
    n -= 1
print(sum(choku))

Measured memory_bytes: 3316
#include <iostream>
#include<vector>
#include <algorithm>
#include <math.h>
using namespace std;
int main(void)
{
	int N;
	cin >> N;
	vector<int> data(N);
	for (int i = 0; i < N; i++)
	{
		cin >> data[i];
	}
	sort(data.begin(), data.end());
	int ans = data[N / 2] - data[(N / 2) - 1];
	cout << ans << endl;
}

Measured memory_bytes: 640
a,b,c,d=[x for x in input()]
op='+-'
for op1 in op:
  for op2 in op:
    for op3 in op:
      ans=a+op1+b+op2+c+op3+d
      if eval(ans)==7:
        print('{}=7'.format(ans))
        exit()
      else:
        pass

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,l,a[100000],MAX,I;

signed main() {
    cin >> n >> l;
    rep(i,n) cin >> a[i];
    rep11(i,n) if (MAX < a[i-1]+a[i]) {
        MAX = a[i-1]+a[i];
        I = i;
    }
    if (MAX < l) {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    rep11(i,I) cout << i << endl;
    for(int i=n-1;i>=I;--i) cout << i << endl;
}


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

int main() {
  
  int x, y, a, b;
  int c = 0; 
  cin >> x >> y;
  
  if ( x == 1||x ==3||x ==5||x ==7||x ==8||x ==10||x ==12) {
    a = 1;
  }
  
  else if ( x == 4||x ==6||x ==9||x ==11 ) {
    a = 2;
  }
  
  if ( y == 1||y ==3||y ==5||y ==7||y ==8||y ==10||y ==12) {
    b = 1;
   
  }
  
  else if ( y == 4|| y ==6|| y ==9|| y ==11 ) {
    b = 2;
  }
    
    
  if ( a == b ) {
    c++;
    }
  
    
  if ( c > 0 ) {
  cout << "Yes" << endl;
  }
    
  if ( c <= 0 ) {
    cout << "No" << endl;
  }
  //cout << a << b;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+5;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int a[N];
char ch[215];
void wt()
{
	for (int i=1;i<=210;i++) cout<<ch[i];
	cout<<endl;
}
int op(int x,int y)
{
	int tmp=x;
	for (int i=1;i<=y;i++) tmp*=2;
	return tmp;
}
signed main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	bool flag=0;
	for (int i=0;i<=k;i++)
	{
		int j=k-i;
		if (a<op(b,i) && op(b,i)<op(c,j)) flag=1;
	}
	if (flag) cout<<"Yes"<<endl;else cout<<"No"<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
ll a, b, c, d;
int main()
{
    ios::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
    cin >> a >> b >> c >> d;
    cout << max({a * c, a * d, b * c, b * d}) << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
//#include <bits/stdc++.h>

#define ll unsigned long long int
#define pb push_back
#define llu unsigned long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define eb emplace_back
#define M 1000000007
#define vi vector<int>
#define vlli vector<lli>
#define pi pair<int,int>
#define mp make_pair
#define mapi map<int,int>

using namespace std;
int min(int x,int y)
{
	if(x<y)
		return x;
	return y;
}
int max(int x,int y)
{
	if(x>y)
		return x;
	return y;
}
bool compare_float(double x, double y, double epsilon = 0.0000001f){
   if(fabs(x - y) < epsilon)
      return true; //they are same
      return false; //they are not same
}
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    ll temp = 1000 - ( n % 1000);
    if(temp == 1000)	cout << "0";
    else cout << temp;
    //cin.ignore(numeric_limits<streamsize>::max(),'\n');
    //const unsigned ll M=1000000007;
    
	//cout << lol;
    return 0;
}



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

int main(){
  ll n,pp=0;
  cin>>n;
  string s;
  cin>>s;
  for(int i=0;i<n;i++){
    if(s[i]=='1')pp++;
  }
  ll a[n],b[n];
  a[0]=1%(pp+1);
  for(int i=1;i<n;i++){
    a[i]=(a[i-1]*2)%(pp+1);
  }
  if(pp-1>0){
    b[0]=1%(pp-1);
    for(int i=1;i<n;i++){
      b[i]=(b[i-1]*2)%(pp-1);
    }
  }
  ll xa=0,xb=0;
  for(int i=0;i<n;i++){
    if(s[n-1-i]=='1'){xa+=a[i];xa%=(pp+1);}
  }
  if(pp-1>0){
    for(int i=0;i<n;i++){
      if(s[n-1-i]=='1'){xb+=b[i];xb%=(pp-1);}
    }
  }
  for(int i=0;i<n;i++){
    ll nowx,npp,ans=1;
    if(s[i]=='0'){
      npp=pp+1;
      nowx=xa+a[n-1-i];nowx%=npp;
      if(nowx==0){cout<<1<<endl;continue;}
      while(nowx>0){
        npp=__builtin_popcount(nowx);
        nowx%=npp;
        ans++;
      }
    }
    else{
      npp=pp-1;
      if(npp==0){cout<<0<<endl;continue;}
      else{
        nowx=xb-b[n-1-i]+npp;nowx%=npp;
        if(nowx==0){cout<<1<<endl;continue;}
        while(nowx>0){
          npp=__builtin_popcount(nowx);
          nowx%=npp;
          ans++;
        }
      }
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 6832
#include<bits/stdc++.h>
using namespace std;
const int maxn=25;
const int maxmask=2097155;
const int mod=1e9+7;
bool valid[maxn][maxn];
int num[maxmask],my_popcount[maxmask];
vector<int> useful[maxn];
void fl()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
int main()
{
//    fl();
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			scanf("%d",&valid[i][j]);
	for(int i=0;i<(int)(1<<n);i++)
	{
		my_popcount[i]=my_popcount[i>>1]+(i&1);
		useful[my_popcount[i]].push_back(i);
	}
	num[0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<(int)useful[i].size();j++)
		{
			int now=useful[i][j];
			for(int k=1;k<=n;k++)
				if(valid[i][k]&&(now&(1<<(k-1))))
				{
					int pre=now&(~(1<<(k-1)));
					num[now]=num[now]+num[pre]-(num[now]+num[pre]>=mod)*mod;
				}
		}
	int ans=num[(1<<n)-1];
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 29128
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

ll f[200001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
 


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxtl();
    ll test=0;
    for(int i=1;i<=n;i++)
    {
        test+=(i)*(n+1-i);
    }
    for(int i=1;i<=n-1;i++)
    {
        ll u=nxtl(),v=nxtl();
        if(v<u)
        {
            ll temp=u;
            u=v;
            v=temp;
        }
        test-=(u*(n+1-v));
    }
    cout<<test<<endl;
    


    return 0;   
}


 
 


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

int dp[11];
string l;

int main(){
	while(cin >> l , l != "0"){
		int i = 0;
		while(l[i] == '0')i++;
		for(int i = 0 ; i < 11 ; i++) dp[i] = 0;
		int sum = 0 , ans = 0;
		dp[0] = 1;
		for( ; i < l.size() ; i++){
			int d = l[i] - '0';
			sum = (sum+(i%2?1:-1)*d+11)%11;
			ans += dp[sum];
			dp[sum] += l[i+1]!='0';
		}
		cout << ans << endl;
	}
}
/*
11011

*/

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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; }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
	vl xs(N), ys(N), hs(N);
	REP(i,N) cin >> xs[i] >> ys[i] >> hs[i];
	REP(x,101) {
		REP(y,101) {
			ll fixed_height = -1;
			ll max_limit = numeric_limits<ll>::max();
			bool ng = false;
			REP(i,N) {
				if (hs[i] == 0) {
					ll tmp = abs(xs[i] - x) + abs(ys[i] - y);
					if (tmp < fixed_height) {
						ng = true;
					}
					chmin(max_limit, tmp);
				} else {
					ll tmp_height = abs(xs[i] - x) + abs(ys[i] - y)+ hs[i];
					if (tmp_height > max_limit) {
						ng = true;
					}
					if (fixed_height != -1 && fixed_height != tmp_height) {
						ng = true;
					}
					fixed_height = tmp_height;
				}
			}
			if (ng) continue;
			if (fixed_height == -1) {
				cout << x << " " << y << " " << max_limit << endl;
				return;
			} else {
				cout << x << " " << y << " " << fixed_height << endl;
				return;
			}
		}
	}
}

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


Measured memory_bytes: 3644
from collections import Counter

N, M = map(int, input().split())
adjL = [[] for _ in range(N)]
degs = [0] * N
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    adjL[a].append(b)
    adjL[b].append(a)
    degs[a] += 1
    degs[b] += 1

cnt = Counter(degs)

if any([key%2 for key in cnt.keys()]):
    print('No')
else:
    cnt[2] = 0
    if sum(cnt.values()) >= 4 or max(cnt.keys()) >= 6:
        print('Yes')
    elif cnt[4] < 2:
        print('No')
    else:
        useds = [False] * N
        vs = []
        for v in range(N):
            if degs[v] == 4:
                useds[v] = True
                vs.append(v)
        for v2 in adjL[vs[0]]:
            v, vPar = v2, vs[0]
            while not useds[v]:
                useds[v] = True
                for v2 in adjL[v]:
                    if v2 != vPar:
                        vPar = v
                        v = v2
                        break
        if all(useds):
            print('No')
        else:
            print('Yes')


Measured memory_bytes: 22992
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, X;
  cin >> K >> X;
  int y = K - 1;
  int q = X - y;
  int z = X + y;
  for (int i = q; i <= z; i++) {
    cout << i << " ";
  }
  cout << endl;
}

Measured memory_bytes: 256
s = str(input())
if s == 'SUN':
    print(7)
if s == 'MON':
    print(6)
if s == 'TUE':
    print(5)
if s == 'WED':
    print(4)
if s == 'THU':
    print(3)
if s == 'FRI':
    print(2)
if s == 'SAT':
    print(1)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
void err(istream_iterator<string>) {}
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << endl; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/
const int N = 401;
i64 dp[N][N], a[N];
i64 go(int l, int r) {
  if (l + 1 == r) return 0LL;
  i64 &res = dp[l][r];
  if (~res) return res;
  res = INF;
  i64 sum = a[l];
  for (int i = l + 1; i < r; ++i) 
    uin(res, go(l, i) + go(i, r)), sum += a[i];
  return res += sum;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  fill_n(dp[0], N * N, -1);
  int n; cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  cout << go(0, n) << '\n';
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;

int main() {
  int k,a,b;
  int c;
  cin>>k>>a>>b;
  c=a/k;
  if(a==c*k ) {
    cout<<"OK"<<endl;
  }
           else  if(a<=(c+1)*k&&(c+1)*k<=b)cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
}

Measured memory_bytes: 3624