akhauriyash/Code-Regression huggingface dataset:
import bisect, collections, copy, heapq, itertools, math, string
from functools import reduce
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
S = S()
R_num = [n for n, v in enumerate(S) if v == 'R']
G_num = [n for n, v in enumerate(S) if v == 'G']
B_num = [n for n, v in enumerate(S) if v == 'B']


cnt = 0
for r in R_num:
    for g in G_num:
        x = r + g
        if x % 2 == 0:
            if x // 2 in B_num:
                cnt += 1
for g in G_num:
    for b in B_num:
        x = g + b
        if x % 2 == 0:
            if x // 2 in R_num:
                cnt += 1
for r in R_num:
    for b in B_num:
        x = r + b
        if x % 2 == 0:
            if x // 2 in G_num:
                cnt += 1

ans = len(R_num) * len(G_num) * len(B_num) - cnt
print(ans)

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;


bool func(const vi& a, const vi& b){
    rep(k, a.size()){
        if(a[k] != b[k])return false;
    }
    return true;
}

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);

    string s, t;
    cin >> s >> t;

    vvi a(26, vi(0)),b(26,vi(0));
    int n = s.size();

    rep(i, n){
        a[s[i]-'a'].pb(i);
        b[t[i]-'a'].pb(i);
    }
    
    //rep(j, 26)debug(a[j].size())
    

    rep(i, 26){
        bool f = false;
        if(a[i].size() == 0)continue;
        rep(j, 26){
            if(b[j].size() ==0 || a[i].size() != b[j].size())continue;
            if(func(a[i], b[j])){
                f = true;
                break;
            }

        }
        
        if(!f){
            cout << "No" << "\n";
            return 0;
        }

    }
    cout << "Yes" << "\n";
    return 0;
}


Measured memory_bytes: 3092
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
#INF = float("inf")
N = int(input())
A = list(map(int,input().split()))
s = 0
for i in A:
    s += i**(-1)
print(s**(-1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	int d;
	while(cin >> d) {
		int cnt = 0;
		for(int i = d; i < 600; i += d) {
			cnt += i * i * d;
		}
		cout << cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 3016
H,W = map(int,input().split())
s = [list(input()) for i in range(H)]
for i in range(H):
	for j in range(W):
		if s[i][j] == "#":
			if s[max(0,i-1)][j] == "." and s[min(H-1,i+1)][j] == "." and s[i][max(0,j-1)] == "." and s[i][min(W-1,j+1)] == ".":
			    print("No")
			    exit()
print("Yes") 

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    int n, m;
    cin >> n >> m;
    int l[m], r[m];
    int mx = n;
    int mn = 1;
    rep(i, m) {
        cin >> l[i] >> r[i];
        mx = min(mx, r[i]);
        mn = max(mn, l[i]);
    }
    // cout << mx << " " << mn << endl;
    cout << max(mx - mn + 1, 0) << endl;
}

Measured memory_bytes: 4412
def func(S,life):
  #life = life
  ans_chr = []
  for i in range(len(S)):
    
    s = S[i]
    if life[s[0]] > life[s[1]]:
      life[s[0]]-=1
      life[s[1]]+=1
      ans_chr.append(s[1])
      #print(life)
      continue
    elif life[s[0]] < life[s[1]]:
      life[s[1]]-=1
      life[s[0]]+=1
      ans_chr.append(s[0])
      #print(life)
      continue
    else:
      if life[s[0]] ==0 and  life[s[1]] ==0:
        return ["No"]
      else:
        if i==len(S)-1:
          ans_chr.append(s[0])
          continue
        else:
          if s[0] in S[i+1]:
            life[s[1]]-=1
            life[s[0]]+=1
            ans_chr.append(s[0])
            #print(life)
          else:
            life[s[0]]-=1
            life[s[1]]+=1
            ans_chr.append(s[1])
            #print(life)
  return ["Yes",ans_chr]
     
      
            
          

lst = list(map(int,input().split()))
N = lst[0]
A,B,C = lst[1:]
life = {"A":A,"B":B,"C":C}
S = []
for i in range(N):
  s = input()
  S.append(s)
ans = func(S,life)
if ans[0]=="No":
  print("No")
else:
  print("Yes")
  for c in ans[1]:
    print(c)
  

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

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
//

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

//main function here

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int c=0;
    vector<int > a;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='L')
            c++;
        else
        {
            if(c)
            a.pb(c);
            c=0;
        }
    }
    if(c)
        a.pb(c);
    c=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
            c++;
        else
        {
            if(c)
            a.pb(c);
            c=0;
        }
    }
    if(c)
        a.pb(c);
    sort(a.rbegin(),a.rend());
    // tr(a,i)
    // cout<<*i<<" ";
    // cout<<"\n";
    // tr(b,i)
    // cout<<*i<<" ";
    // cout<<"\n";
    ll sum=0;
    for(int i=0;i<a.size();i++)
    {
        if(i<k)
            sum+=a[i]+1;
        else
            sum+=a[i]-1;
    }
    cout<<min(sum,n-1)<<"\n";
  return 0;
 }


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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

const int mod=1000000007;

int main(){
    int a,b;
    cin>>a>>b;
    int wmap[50][100];
    int bmap[50][100];

    memset(wmap,0,sizeof(bmap));
    rep(i,50) rep(j,100) bmap[i][j]=1;

    while(--a){
        wmap[2*((a-1)/50)][((a-1)%50)*2]=1;
    }
    while(--b){
        bmap[2*((b-1)/50)][((b-1)%50)*2]=0;
    }
    cout<<100<<" "<<100<<endl;
        rep(i,49){
        rep(j,100){
            if(wmap[i][j]==1) cout<<'.';
            else cout<<'#';
        }
        cout<<endl;
    }
    rep(j,100)cout<<'.';
    cout<<endl;
    rep(i,50){
        rep(j,100){
            if(bmap[i][j]==1) cout<<'.';
            else cout<<'#';
        }
        cout<<endl;
    }
}

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

using ll = long long;
using P  = std::pair< ll, ll >;

void solve( std::vector< P > vec ) {
    ll t = 0;
    bool flag = true;
    for (auto v : vec) {
        if ( v.second + t > v.first ) {
            flag = false;
            break;
        }
        t += v.second;
    }
    std::cout << ( flag ? "Yes" : "No" ) << std::endl;
}

int main() {
    int n;
    std::vector< P > vec;
    std::cin >> n;
    for (int i=0; i<n; ++i) {
        P tmp;
        std::cin >> tmp.second >> tmp.first;
        vec.push_back( tmp );
    }
    std::sort(vec.begin(), vec.end());
    solve( vec );
    return 0;
}


Measured memory_bytes: 7404
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args) throws Exception{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int l = scan.nextInt();

		ArrayList<ArrayList<Integer>> load = new ArrayList<>(n);
		ArrayList<ArrayList<Integer>> rail = new ArrayList<>(n);
		for(int i = 0; i < n; i++) {
			load.add(new ArrayList<Integer>());
			rail.add(new ArrayList<Integer>());
		}

		for(int i = 0; i < k; i++) {
			int p = scan.nextInt()-1;
			int q = scan.nextInt()-1;
			load.get(p).add(q);
			load.get(q).add(p);
		}

		for(int i = 0; i < l; i++) {
			int p = scan.nextInt()-1;
			int q = scan.nextInt()-1;
			rail.get(p).add(q);
			rail.get(q).add(p);
		}

		boolean[] flagMap = new boolean[n];
		int groupNum = 0;
		int[] loadGroup = new int[n];
		for(int i = 0; i < n; i++) {
			int result = check(load,i,flagMap,groupNum,loadGroup);
			if(result>0) {
				groupNum++;
			}
		}

		flagMap = new boolean[n];
		groupNum = 0;
		int[] railGroup = new int[n];
		for(int i = 0; i < n; i++) {
			int result = check(rail,i,flagMap,groupNum,railGroup);
			if(result>0) {
				groupNum++;
			}
		}
/*
		for(int i = 0; i < n; i++) {
			System.out.printf("ldGrp:%d,rlGrp:%d\n",loadGroup[i],railGroup[i]);
		}
*/
		HashMap<Long,Integer> map = new HashMap<>();
		for(int i = 0; i < n; i++) {
			long hash = getHash(railGroup[i],loadGroup[i]);
			if(map.containsKey(hash)) map.put(hash, map.get(hash)+1);
			else map.put(hash, 1);
		}

		StringBuilder sb = new StringBuilder(n*2);
		for(int i = 0; i < n; i++) {
			//System.out.println(getHash(railGroup[i],loadGroup[i]));
			sb.append(map.get(getHash(railGroup[i],loadGroup[i])));
			sb.append("\n");
		}
		System.out.println(sb.toString());
	}

	static long getHash(int x, int y) {
		return x*1000000L+(long)y;
	}

	static int check(ArrayList<ArrayList<Integer>> list, int start, boolean[] flagMap, int groupNum, int[] group) {
		if(flagMap[start]) return 0;
		flagMap[start] = true;
		group[start] = groupNum;
		int sum = 0;
		for(int next : list.get(start)) {
			sum += check(list,next,flagMap,groupNum,group);
		}
		return 1 + sum;
	}
}


Measured memory_bytes: 152472
n = int(input())
a = list(map(int,input().split()))
flag = 1

for i in a:
  if i % 2 == 0:
    if i % 3 == 0 or i % 5 == 0:
      flag = 1
    else:
      flag = 0
      break
  
if flag == 1:
  print('APPROVED')
else:
  print('DENIED')
  


Measured memory_bytes: 2940
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;


typedef vector<vector<int> > graph_t;


class SCC {
public:
  SCC(int _n, int _k) : n(_n), k(_k), g(_n), gr(_n) {
    visisted.assign(n, false);
  }

  void solve() {
    for (int i = 0; i < k; ++i) {
      int u, v;
      scanf("%d %d", &u, &v);
      g[u].push_back(v);
      gr[v].push_back(u);
    }

    vector<int> order;
    for (int i = 0; i < n; ++i) {
      if (!visisted[i])
        dfs(i, g, order);
    }
    reverse(order.begin(), order.end()); 

    visisted.assign(n, false);
    id.assign(n, -1);
    int cnt = 1;
    for (int i = 0; i < n; ++i) {
      int u = order[i];
      if (!visisted[u]) {
        vector<int> component;
        dfs(u, gr, component);
        for (vector<int>::iterator it = component.begin(); it != component.end(); ++it) {
          id[*it] = cnt;
        }
        ++cnt;
      }
    }
  }

  bool same_component(int u, int v) {
    return id[u] == id[v];
  }

private:
  void dfs(int u, graph_t& g, vector<int>& res) {
    visisted[u] = true;

    for (size_t i = 0; i < g[u].size(); ++i) {
      int to = g[u][i];
      if (!visisted[to])
        dfs(to, g, res);
    }

    res.push_back(u);
  }
private:
  int n, k;
  graph_t g, gr; 
  vector<bool> visisted;
  vector<int> id;
};


void scc_query(SCC& scc, int u, int v) {
  if (scc.same_component(u, v))
    printf("1\n");
  else
    printf("0\n");
}

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

  SCC scc(n, k);
  scc.solve();

  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    scc_query(scc, u, v);
  }
  return 0;
}



Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=200000+5;
const int inf=1e9;
const ll mod=1e9+7;


ll a[MX];

int main()
{
    FasterIO;
    ll tc, n, k;
    cin>>n>>k;
    for(int i=1; i<=n; i++) cin>>a[i];
    sort(a+1, a+n+1);
    int id=max(n-k, 0LL);
    ll sm=0;
    for(int i=1; i<=id; i++) sm+=a[i];
    cout<<sm<<endl;
    return 0 ;
}


Measured memory_bytes: 1792
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    string p = "pphbhhphph";
    cout << p[N % 10] << "on" << endl;
}

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int M = scan.nextInt();
			char[][]n = new char[N][N];
			char[][]m = new char[M][M];
			
			for(int i = 0;i<N;i++) {
				String s = scan.next();
				n[i] = s.toCharArray();
			}
			
			for(int i = 0;i<M;i++) {
				String string = scan.next();
				m[i]=string.toCharArray();
			}
			
			for(int i = 0;i<N-M+1;i++) {
				for(int j = 0;j<N-M+1;j++) {
					int count = 0;
					for(int z = 0;z<M;z++) {
						for(int w = 0;w<M;w++) {
							if(m[z][w]==n[i+z][j+w]) {
								count++;
							}
						}
					}
					
					if(count==M*M) {
						System.out.println("Yes");
						System.exit(0);
					}
					
					
				}
			}
			
			System.out.println("No");
			
			
			
		}
		
		
	}
		

}


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

int a, b;
    char op;
    while (cin >> a >> op >> b)
        switch (op) {
            case '+': cout << a+b << endl; break;
            case '-': cout << a-b << endl; break;
            case '*': cout << a*b << endl; break;
            case '/': cout << a/b << endl; break;
        }
    return 0;
}


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

using namespace std;


int main() {
	string s;
	cin >> s;
	int len = s.size();
	long long cnt = 0;
	for (int i = len-1; i >= 0;i--) {
		if (s[i] == 'B') {
			cnt += len - i - 1;
			len--;
		}
	}
	cout << cnt;
}

Measured memory_bytes: 640
def main() -> None:
    N, M = map(int, input().split())
    cards = [(x, 1) for x in map(int, input().split())]
    for _ in range(M):
        b, c = map(int, input().split())
        cards.append((c, b))
    cards.sort(reverse=True)
    res, ans_sum = N, 0
    for x, num in cards:
        if res <= num:
            ans_sum += res * x
            break
        ans_sum += num * x
        res -= num
    print(ans_sum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 28100
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    sort(ALL(A));
    if (N % 2 == 1) {
        for (int i = 0; i < N; i++) {
            if (i == 0) {
                if (A.at(0) != 0) {
                    cout << 0 << endl;
                    return 0;
                }
                else {
                    if (i == N - 1) {
                        cout << 1 << endl;
                        return 0;
                    }
                    continue;
                }
            }
            if (((i + 1) / 2) * 2 != A.at(i)) {
                cout << 0 << endl;
                return 0;
            }
            if (i == N - 1) {
                int a = (N - 1) / 2, ans = 1;

                while(a--) {
                    ans = ans * 2 % 1000000007;
                }
                cout << ans << endl;
            }


        }
    }
    else {
        for (int i = 0; i < N; i++) {
            if ((i / 2) * 2 != A.at(i) - 1) {
                cout << 0 << endl;
                return 0;
            }
            if (i == N - 1) {
                int64_t a = N / 2, ans = 1;

                while(a--) {
                    ans = ans * 2 % 1000000007;
                }
                cout << ans << endl;
            }


        }
    }
}


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


int main() {

    int x;
    cin >> x;
    int count500 = 0;
    int count5 = 0;
    while (x>=500) {
        x = x - 500;
        count500 = count500 + 1;

    }
    while (x >= 5) {
        x = x - 5;
        count5 = count5 + 1;

    }

    cout << count500 * 1000 + count5 * 5 << endl;
}

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

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;



int main() {
    int X, Y;;    
    cin >> X >> Y;
    
    cout << X + Y / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

n, x = map(int,input().split())
cities = list(map(int, input().split()))
min = pow(10,9)
a = []
for i in range(n):
    a.append(abs(x-cities[i]))
for i in range(n-1):
    a[i+1] = gcd(a[i],a[i+1])
print(a[-1])

Measured memory_bytes: 14228
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
const lli M=1e9+7;

lli binpow(lli a,lli b) 
{
    if (b == 0) return 1;
    lli res = binpow(a,b/2);
    res= (res*res)%M;
    
    if(b%2) return (res*a)%M;
    return res;
}
 
lli inv(lli a)
{
    return binpow(a,M-2);
}

lli add(lli a, lli b)
{
	lli res = a + b;
	if(res >= M)
		return res - M;
	return res;
}
 
lli mult(lli a, lli b)
{
	lli  res = a * b;
	if(res >= M)
		return res % M;
	return res;
}
 
lli sub(lli a, lli b)
{
	return (a%M -b%M +M) %M;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n,k;
    cin>>n>>k;
    lli i,j,possible_number,for_one=0,tot[k+1]={0},ans=0;
    
    for(i=k;i>=2;i--)
    {
        possible_number=k/i;
        
        tot[i]=binpow(possible_number, n);
        
        for(j=2*i;j<=k;j+=i) tot[i]=sub(tot[i], tot[j]);
        
        for_one=add(for_one,tot[i]);
        
        ans=add(ans, mult(i, tot[i]));
    }
    ans=add(ans, sub( binpow(k,n), for_one));
    
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>
#include <regex>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = int64_t;

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

void solve(){
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, n){
        cin >> a[i];
    }
    cout << ceil((double)(n-1)/(k-1)) << endl;
}

int main(){
    solve();
    return 0;
}

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

int n,k,z[10005];
string s[1555],t;
bool check(int x,int y){
    for (int i=0;i<n/2;i++) if (t[x+i]!=t[y+i]) return t[x+i]<t[y+i];
    return 0;
}
string solve(string x){
    string y=x; reverse(y.begin(),y.end());
    t=y+x; //get_z();
    int pos=0;
    for (int i=1;i<=n;i++) if (check(i,pos)) pos=i;
    string ret="";
    for (int i=pos;i<pos+n;i++) ret+=t[i];
    return ret;
}
int main(){
    cin >> n >> k >> s[0];
    reverse(s[0].begin(),s[0].end());
    for (int i=1;i<=k;i++){
        s[i]=solve(s[i-1]);
        if (s[i]==s[i-1]) {
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << s[k] << endl;
}


Measured memory_bytes: 384
import sys
from math import ceil

def main():
    n = int(sys.stdin.readline().rstrip())
    x = ceil(n / 1.08)

    res = []
    while x * 27 // 25 == n:
        res.append(x)
        x += 1
    if res:
        print(res[0])
    else:
        print(':(')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()
	N, _, X, Y := sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt()

	x := sc.NextIntArray()
	y := sc.NextIntArray()

	sort.Ints(x)
	sort.Ints(y)

	check := func() bool {
		if x[N-1] >= y[0] {
			return false
		}
		if x[N-1] >= Y {
			return false
		}
		if y[0] <= X {
			return false
		}
		return true
	}()

	if check {
		fmt.Println("No War")
	} else {
		fmt.Println("War")
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main(){
    int A[3],K;
    for (int i=0;i<3;i++) cin >>A[i];
    cin >>K;
    sort(A,A+3);

    for(int i=0;i<K;i++) A[2] *=2;
    int ans =0;
    for (int i=0;i<3;i++) ans+=A[i];

    cout<<ans<<endl;
    

    return 0;
}

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

int main() {
  int N;
  cin>>N;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  int min=1000000;
  for(int p=1;p<100;p++){
    int sum=0;
    for(int i=0;i<N;i++){
      sum+=(vec.at(i)-p)*(vec.at(i)-p);
    }
    if(sum<=min) min=sum;
  }
  
  cout<<min<<endl;
    
    
  
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int i,n,L[5],N[5],S[5],num=0;
	for(i=0;i<=4;++i){
		N[i]=0;
		L[i]=0;
		S[i]=0;
	}
	while(cin>>n,n){
		while(1){
			if (n==6174){
				cout<<"0"<<endl;
				break;
			}
			L[4]=N[4]=n/1000;
			L[3]=N[3]=n/100-N[4]*10;
			L[2]=N[2]=n/10-N[4]*100-N[3]*10;
			L[1]=N[1]=n-(n/10)*10;
			if (L[1]==L[2] && L[2]==L[3] && L[3]==L[4]){
				cout<<"NA"<<endl;
				break;
			}
			for(int j=1;j<=4;++j){
				for(i=4;i>=2;--i){
					if (L[i]<L[i-1]){
						L[0]=L[i];
						L[i]=L[i-1];
						L[i-1]=L[0];
					}
				}
			}
			for(int j=1,i=4;j<=4,i>=1;++j,--i){
					S[j]=L[i];
			}
			L[0]=L[4]*1000+L[3]*100+L[2]*10+L[1];
			S[0]=S[4]*1000+S[3]*100+S[2]*10+S[1];
			n=L[0]-S[0];
			num+=1;
			if (n==6174){
				cout<<num<<endl;
				num=0;
				break;
			}
		}
	}
	return 0;
}

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

int main(void){
  long N,K;
  cin>>K>>N;
  vector<int> v;
  long _A[N];
  for(int i=0;i<N;i++){
    cin>>_A[i];
  }
  long M=-10000;
  for(int i=0;i<N;i++){
    M=max(min(abs(_A[(i+1)%N]-_A[i]),K-abs(_A[(i+1)%N]-_A[i])),M);
  }
  cout<<K-M<<endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, m, s[10], C[10];
  cin>>n>>m;
  REP(i, m){
    cin>>s[i]>>C[i];
    --s[i];
  }
  int ans=-1;
  REP(i, 1000){
    int x=i;
    int a=x/100;
    int b=(x-a*100)/10;
    int c=x%10;
    // DEBUG(a);DEBUG(b);DEBUG(c);
    bool ok=true;
    int cnt=0;
    if(x==0){
      cnt=1;
    }
    while(x>0){
      x/=10;
      ++cnt;
    }
    if(cnt!=n){
      continue;
    }
    REP(j, m){
      if(n==3 && s[j]==0){
        if(C[j]!=a){
          ok=false;
          break;
        }
      }
      if((n==3 && s[j]==1) || (n==2 && s[j]==0)){
        if(C[j]!=b){
          ok=false;
          break;
        }
      }
      if((n==3 && s[j]==2) || (n==2 && s[j]==1) || (n==1 && s[j]==0)){
        if(C[j]!=c){
          ok=false;
          break;
        }
      }
    }
    if(ok){
      ans=i;
      break;
    }
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 256
# abc 144 d
import math
read = input 
rn = lambda :list(map(int, read().split()))
def reverse_range(r):return range(r-1, -1, -1)
a, b, x = rn()
thres = a * a * b
if x*2 >= thres:
    j = (2*x) / (a*a)
    j -= b
    tan = (b-j) / a
    ans = math.atan(tan)
    ans = math.degrees(ans)
    print(ans)
    pass
else :
    j = (2*x) / (a*b)
    tan = j / b
    ans = math.atan(tan)
    # math.radians()
    print(90 - math.degrees(ans))

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
//const long long mod = 1000000007;
//const long long mod = 998244353;

int main() {
	int A, B;
	scanf("%d %d", &A, &B);
	int res = A * B;
	if (A > 9 || B > 9)res = -1;
	printf("%d", res);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1e9 + 7

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

    int n;

    cin >> n;

    vector<int> a(n);

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

    long long ans = 0,s = 0;
    unordered_map<long long,long long> m;

    m[0] = 1;
    for(int i = 0;i < n;i++)
    {
        s+=a[i];
        ans+=m[s];
        m[s]++;
    }

    cout << ans;
}


Measured memory_bytes: 9288
n=int(input())
pl = []
for i in range(n):
	a,b = map(int,input().split())
	pl.append((a,b))
pl = sorted(pl, key=lambda x:x[1])
t = 0
for i in pl:
	memo = t+i[0]
	if memo > i[1]:
		print("No")
		exit()
	t = memo
print("Yes")


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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int>d(k);
  vector<vector<int>>A(k,vector<int>(n,0));
  vector<int>unko(n,0);
  int count=0;
  rep(i,k){
    cin>>d.at(i);
    rep(j,d.at(i)){
      cin>>A.at(i).at(j);
      unko.at(A.at(i).at(j)-1)=1;
    }
  }
  rep(i,n)if(unko.at(i)==0)count++;
  cout<<count<<endl;

}


Measured memory_bytes: 3676
N, K = gets.chomp.split(' ').map(&:to_i)
h_list = N.times.map { gets.to_i }
sorted_h_list = h_list.sort
min_diff = 10 ** 9 + 1
answer = (N - K + 1).times do |i|
  diff = sorted_h_list[i + K - 1] - sorted_h_list[i]
  min_diff = diff if diff < min_diff
end
puts min_diff


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

const int maxn=500005;
typedef long long ll;

int read()
{
	int f=0; char c=getchar();
	while(c>'9' || c<'0') c=getchar();
	while(c<='9' && c>='0') {f=f*10+c-'0'; c=getchar();}
	return f;
}

ll n,k;

int main()
{
	cin>>n>>k;
	cout<<min(n%k,k-n%k)<<endl;
	return 0;
}

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

int main(){
    vector<vector<int>> a(3,vector<int>(3));
    vector<vector<bool>> a_m(3,vector<bool>(3));    
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin>>a.at(i).at(j);
            a_m.at(i).at(j)=false;
        }
    }

    int n;
    cin>>n;

    vector<int> b(n);
    for(int i=0; i<n; i++){
        cin>>b.at(i);
    }

    bool bingo=false;

    // ビンゴカードに印をつける
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            for(int l=0; l<n; l++){
                if(a.at(i).at(j)==b.at(l)){
                    a_m.at(i).at(j)=true;
                }
            }
        }
    }

    // 縦のビンゴを判定
    for(int i=0; i<3; i++){
        if(a_m.at(i).at(0)==true && a_m.at(i).at(1)==true && a_m.at(i).at(2)==true){
            bingo=true;
        }
    }

    // 横のビンゴを判定
    for(int i=0; i<3; i++){
        if(a_m.at(0).at(i)==true && a_m.at(1).at(i)==true && a_m.at(2).at(i)==true){
            bingo=true;
        }
    }

    // 斜めのビンゴを判定
    if((a_m.at(0).at(0)==true && a_m.at(1).at(1)==true && a_m.at(2).at(2)==true) || (a_m.at(2).at(0)==true && a_m.at(1).at(1)==true && a_m.at(0).at(2)==true)){
        bingo=true;
    }

    if(bingo==true){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

/* https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/3/ALDS1_3_D
input:
\\//
output:
4
1 4
input2:
\\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\
output2:
35
5 4 2 1 19 9
 */
int main() {
    stack<int> S1;
    stack<pair<int, int> > S2;
    int total_area = 0;
        // , area_count = 0;

    char c;
    for(int i = 0; scanf("%c", &c) != EOF; i++) {
        if(c == '\\') {
            S1.push(i);
        } else if(c == '/' && S1.size() > 0) {
            int j = S1.top(); S1.pop();
            total_area += i - j;

            int a = i - j;
            while(S2.size() > 0 && S2.top().first > j) {
                a += S2.top().second; S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }


    printf("%d\n", total_area);
    vector<int> ans;
    while(S2.size()) {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(), ans.end());
    printf("%d", ans.size());
    for(int i = 0; i < ans.size(); i++) printf(" %d", ans[i]);
    printf("\n");

    return 0;
}



Measured memory_bytes: 2844
s = gets.chomp

if s[0] != 'A'
  puts 'WA'
  exit
end
s[0] = ''

c = s[1..-2].index('C')
if !c
  puts 'WA'
  exit
end
s[c+1] = ''

if s.downcase != s
  puts 'WA'
else
  puts 'AC'
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define MAXN 21010
#define Scan(a) scanf("%I64d", &a)
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

string s;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> s;
    int l, r;
    FOR(i,0,s.length()-1)
        if (s[i] == 'A') {
            l = i;
            break;
        }
    FORE(i,s.length()-1,0)
        if (s[i] == 'Z') {
            r = i;
            break;
        }
    cout << r-l+1;
    return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define SORT(x) (sort(x.begin(),x.end()))
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll N,A[100007],B[100007],e=0,y=0,f=MOD;
    cin >> N;
    rep(i,N){
        cin >> A[i] ;
        if(A[i]<0) e++;
        B[i]=abs(A[i]);
        y+=B[i];
        if(f>B[i]) f=B[i];
    }
    cout << (e%2==1 ? y-2*f : y) <<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vi cntp(n, 0);
    vb ac(n, false);
    int penalty = 0;
    rep(i, m) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (s == "AC") {
            if (!ac[p]) {
                ac[p] = true;
                penalty += cntp[p];
            }
        } else {
            cntp[p]++;
        }
    }
    cout << accumulate(ac.begin(), ac.end(), 0) << " " << penalty << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n,m=250;
int S[300][300];
vector<P> v;

void plot(ll x,ll y){
    int cnt2=0,cnt5=0;
    while(x%2==0){
        x/=2;
        cnt2+=1;
    }
    while(y%2==0){
        y/=2;
        cnt2-=1;
    }
    while(x%5==0){
        x/=5;
        cnt5+=1;
    }
    while(y%5==0){
        y/=5;
        cnt5-=1;
    }
    S[cnt2+100][cnt5+100]+=1;
    v.push_back(P(cnt2,cnt5));
}

void solve(){
    cin >> n;
    rep(i,n){
        ll a=0,b=1;string s;
        cin >> s;
        bool flag=false;
        rep(i,s.length()){
            if(s[i]=='.') flag=true;
            else{
                if(flag) b*=10;
                a*=10;
                a+=s[i]-'0';
            }
        }
        plot(a,b);
    }
    rep(i,m) rep(j,m) {
        S[i][j+1]=S[i][j]+S[i][j+1];
    }
    rep(j,m+1) rep(i,m) {
        S[i+1][j]=S[i][j]+S[i+1][j];
    }
    ll ans=0;
    rep(i,n){
        int x=v[i].first,y=v[i].second;
        ans+=S[m][m]-S[-x+99][m]-S[m][-y+99]+S[-x+99][-y+99];
        if(x>=0 && y>=0) ans-=1;
    }
    cout << ans/2 << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 5340
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int D, N;
  cin >> D >> N;
   int ans;
  if(N!=100){
  ans = N;
  }
  else ans = 101;
  for(int i=0; i<D; ++i) ans = ans * 100;
  cout << ans;


  return 0;
}


Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            佛祖保佑       永无BUG
*/
#include<stdio.h>
#include<cstring>
#define re register
using namespace std;
int n,a,x[51],v=2505;
long long dp[2][51*51*2]; 
int main()
{
	scanf("%d%d",&n,&a);
	for(re int i=1;i<=n;++i)
	{
		scanf("%d",&x[i]);
		x[i]-=a;
	}
	int cur=0;
	dp[cur][v]=1;
	for(re int i=1;i<=n;++i)
	{
		memset(dp[cur^1],0,sizeof(dp[cur^1]));
		for(re int j=0;j<=2*v;++j)
		{
			if(j+x[i]>=0)
				dp[cur^1][j+x[i]]+=dp[cur][j];
			dp[cur^1][j]+=dp[cur][j];
		}
		cur^=1;
	}
	printf("%lld\n",dp[cur][v]-1);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n, k; std::cin >> n >> k;
    bool used[102] = {};
    for (int i = 0; i < k; i++) {
        int d; std::cin >> d;
        for (int j = 0; j < d; j++) {
            int a; std::cin >> a;
            a--;
            used[a] = true;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) ans += !used[i];
    std::cout << ans << std::endl;
    return 0;
}



Measured memory_bytes: 3636
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}

int log(int x) {
    int i;
    for(i=0;(1ll<<i)<=x;i++);
    return i;
}
 
int32_t main() {
    fio
    
    cout << fixed << setprecision(15);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int x=c-a,y=d-b;
    cout << c-y << " " << d+x << " " << a-y << " " << b+x;
    
	return 0;
    
}

Measured memory_bytes: 8832
N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
p = 0
for i in range(N-2):
    if A[i] == B[i] and A[i+1] == B[i+1] and A[i+2] == B[i+2]:
        print("Yes")
        break
    else:
        p += 1
if p == N-2:
    print("No")
        

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

using namespace std;
using ll = long long;

long long lgpow(long long b, long long p) {
    long long res = 1;
    while (p) {
        if (p & 1) res *= b;
        b *= b;
        p >>= 1;
    }
    return res;
}


int main()
{
    ll n, p, p_copy, power_cnt = 0, max_div = 1;
    cin >> n >> p;
    p_copy = p;

    while (p_copy % 2 == 0)
    {
        power_cnt++;
        p_copy = p_copy / 2;
    }
    if(power_cnt / n > 0)
        max_div *= lgpow(2, power_cnt / n);


    ll i = 3;
    while(p_copy > 1)
    {
        power_cnt = 0;
        while (p_copy % i == 0)
        {
            power_cnt++;
            p_copy = p_copy / i;
        }
        if(power_cnt / n > 0)
            max_div *= lgpow(i, power_cnt / n);
        i += 2;
        if(i * i > p_copy) break;
    }
    if(n == 1 ) max_div *= p_copy;
    cout << endl << max_div;
}


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

int main(){
    string s,str;
    string::size_type sz;
    while(getline(cin,str)){
        vector<string>vec;
        vector<double>v;
        s="";
        for(int i=0;i<str.length();i++){
            while((str[i]!=' '&&i<str.length())||(i<str.length()-1&&str[i]=='-'&&str[i+1]>='0'&&str[i]<='9')){
                s=s+str[i];
                i++;
            }
            vec.push_back(s);
            s="";
        }
        vec.push_back(s);
        double a,b,t;
        for(int i=0;i<vec.size();i++){
            if(vec[i].length()==1&&(vec[i][0]<'0'||vec[i][0]>'9')){
                a=v[v.size()-2];
                b=v[v.size()-1];
                if(vec[i][0]=='+')
                    t=a+b;
                if(vec[i][0]=='-')
                    t=a-b;
                if(vec[i][0]=='*')
                    t=a*b;
                if(vec[i][0]=='/')
                    t=a/b;
                v.pop_back();
                v.pop_back();
                v.push_back(t);
            }
            else{
                v.push_back(atof(vec[i].c_str()));
                
            }
        }
        printf("%.6f\n",v[0]);
    }
}

Measured memory_bytes: 1268