akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	ans := 0
	for i := 105; i <= N; i = i + 2 {
		if numOfDivisor(i) == 8 {
			ans++
		}
	}
	fmt.Println(ans)
}

func numOfDivisor(n int) int {
	facts := make(map[int]int)
	factoring(n, facts)

	ret := 1
	for _, count := range facts {
		ret = ret * (count + 1)
	}
	return ret
}

func factoring(n int, facts map[int]int) {
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			facts[i]++
			n = n / i
		}
	}
	if n != 1 {
		facts[n]++
	}
}


Measured memory_bytes: 640
import java.util.Scanner;
class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
            String T=sc.nextLine();
            for(int i=0;i<T.length();i++){
            	if(Character.isUpperCase(T.charAt(i)))
                    System.out.print(Character.toLowerCase(T.charAt(i)));
                else if(Character.isLowerCase(T.charAt(i)))
                    System.out.print(Character.toUpperCase(T.charAt(i)));
                else 
                    System.out.print(T.charAt(i));
        } 
        System.out.println();
        sc.close();
    }
}


Measured memory_bytes: 26892
#include <iostream>
using namespace std;
#include <bits/stdc++.h>
int main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    int sum=0;
    int arr[n];

   int counter=0;
    for(int i =0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(int i =0;i<k;i++)
    {
sum += arr[i];
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3616
# coding: utf-8

H, W = map(int, raw_input().split())

c = [map(int, raw_input().split()) for _ in xrange(10)]
A = [map(int, raw_input().split()) for _ in xrange(H)]
d = [float('inf')] * 10

def bellman_ford(s):
    d[s] = 0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                if d[j] != float('inf') and d[k] > d[j] + c[k][j]:
                    d[k] = d[j] + c[k][j]

bellman_ford(1)
ans = 0

for i in A:
    for j in i:
        if j != -1:
            ans += d[j]

print ans
# print sum(sum(d[a] if a != -1 else 0 for a in aa) for aa in A)


Measured memory_bytes: 2948
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;

map<int, vector<int>> d;
bool vis[200001];

void dfs(int i) {
    vis[i] = true;
    for (int e : d[i]) {
        if (!vis[e]) {
            dfs(e);
        }
    }
}

int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n, m;
    cin >> n >> m;


    int x, y, z;
    while (m--) {
        cin >> x >> y >> z;
        d[x].pb(y);
        d[y].pb(x);
    }

    int ans = 0;

    memset(vis, false, sizeof vis);

    for (int i = 1; i <= n; i++) {
        if (!vis[i]) {
            ans++;
            dfs(i);
        }
    }

    cout << ans;
}

Measured memory_bytes: 19200
def check_2(s):
    n = s.__len__()
    x = (n-1)/2
    x = abs(x)
    x = int(x)
    temp = s[0:x]
    if isPalindrome(temp) == 1:
        return 1
    else:
        return 0

def check_3(s):
    n = s.__len__()
    x = (n + 3) / 2
    x = abs(x)
    x = int(x)
    temp = s[n:x]
    if isPalindrome(temp) == 1:
        return 1
    else:
        return 0
def reverse(s):
    return s[::-1]


def isPalindrome(s):
    # Calling reverse function
    rev = reverse(s)

    # Checking if both string are equal or not
    if (s == rev):
        return 1
    return 0

if __name__ == "__main__":
    s = input()
    result = 0
    if isPalindrome(s) == 1:
        result = 1
        if check_2(s) == 1:
            result = 1
            if check_3(s) == 1:
                result = 1
            else:
                result = 0
        else:
            result = 0
    else:
        result = 0
    if result == 1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  ll ans=0ll;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }

  ll right=0ll;
  ll sum=0ll;
  for(int left=0;left<N;left++){
    while(right<N&&((sum^A[right])==sum+A[right])){
      sum = sum^A[right];
      right++;
    }
    ans+=right-left;
    if(right==left){
      right++;
    }else{
      sum=sum^A[left];
    }
  }
  cout<<ans<<endl;
}


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

int main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	int g = 500 * f + (100 * e) + (50 * d) + (10 * c) + (5 * b) + a;
	if (g >= 1000)cout << 1 << endl;
	else cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 3080
N = int(input())
A = list(map(int, input().split()))


C = 0
for i, v in enumerate(A):
    if v < 0:
        C += 1
if C % 2 == 0:
    ans = 0
    for i, v in enumerate(A):
        ans += abs(v)
else:
    A = sorted([abs(a) for a in A])
    ans = sum(A) - 2*A[0]

print(ans)

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


int* mallocint(int si)
{
    return (int*) malloc(si * sizeof(int));
}

int* inputint(int n)
{
    int *ans = mallocint(n);
    for( int i = 0; i < n; i++ ) cin >> ans[i];
    return ans;
}

int main()
{
    int c, k, n;
    cin >> n >> k >> c;
    int *s = new int[n];
    int index = 0;
    while( index < n )
    {
        char c;
        cin >> c;
        char tmp = -1;
        if( c == 'o') tmp = 0;
        if( c == 'x') tmp = 1;
        if( tmp >= 0 ) s[index++] = tmp;
    }

    // i日目から全力で働いた場合の働ける日数
    int *fr = new int[n];
    for( int i = n - 1; i >= 0; i-- )
    {
        int pre = 0;
        if( i < n - 1 ) pre = fr[i + 1];
        if( s[i] == 0 )
        {
            if( i + c + 1 < n )
            {
                fr[i] = 1 + fr[i + c + 1];
            }
            else
            {
                fr[i] = 1;
            }
        }
        else
        {
            fr[i] = pre;
        }
    }

    if( fr[0] > k )
    {
        // k + 1日働けるので、どの日も休める
        return 0;
    }    

    // 左から一番働いたときの働いた累積日数
    bool flag = false;
    int left = fr[0];
    int r = 0;

    for( int i = 0; i < n; i++ )
    {
        bool restflag = ( r > 0);
        if( r > 0 ) r--;
        if( left != fr[i] )
        {
            flag = false;
            left = fr[i];
        }

        {
            if( !flag && !restflag )
            {
                if( s[i] == 0 )
                {
                    if( i + 1 >= n || fr[i + 1] != left )
                    {
                        cout << (i + 1) << endl;
                    }
                    flag = true;
                    r = c;
                }
            }
        }
    }
}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
using namespace std;
vector<int> b(pow(8,8),-1);
int gethash(vector<int> v){
    int a=0;
    for(int i=0;i<8;i++){
        a=a*8+v[i];
    }
    return a;
}

void haba(vector<int> v){
    queue<pair<vector<int>,int>> q;
    q.push({v,0});
    while(!q.empty()){
        vector<int> t=q.front().first;
        int c=q.front().second;
        b[gethash(t)]=c;
        q.pop();
        vector<int> t1=t,t2=t,t3=t,t4=t;
        for(int i=0;i<8;i++){
            if(t[i]==0&&i!=3&&i!=7){
                swap(t1[i],t1[(i+1)%8]);
                if(b[gethash(t1)]==-1)q.push({t1,c+1});
            }
        }
        for(int i=0;i<4;i++){
            if(t[i]==0){
                swap(t2[i],t2[(i+4)%8]);
                if(b[gethash(t2)]==-1)q.push({t2,c+1});
            }
        }
        for(int i=0;i<8;i++){
            if(t[i]==0&&i!=0&&i!=4){
                swap(t3[i],t3[(i-1)%8]);
                if(b[gethash(t3)]==-1)q.push({t3,c+1});
            }
        }
        for(int i=4;i<8;i++){
            if(t[i]==0){
                swap(t4[i],t4[(i+4)%8]);
                if(b[gethash(t4)]==-1)q.push({t4,c+1});
            }
        }
    }
}

void solve(vector<int> v){
    cout<<b[gethash(v)]<<endl;
}

int main(void){
    int a,b,c,d,e,f,g,h;
    vector<int> v={0,1,2,3,4,5,6,7};
    haba(v);
    while(cin>>a>>b>>c>>d>>e>>f>>g>>h){
        vector<int> v;
        v.push_back(a);
        v.push_back(b);
        v.push_back(c);
        v.push_back(d);
        v.push_back(e);
        v.push_back(f);
        v.push_back(g);
        v.push_back(h);
        solve(v);
    }
}



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

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

    std::vector<std::vector<int>> xss(n, std::vector<int>(n, -1));

    for (auto& xs : xss) {
        int a;
        std::cin >> a;

        while (a--) {
            int x;
            std::cin >> x;
            --x;
            std::cin >> xs[x];
        }
    }

    int ans = 0;
    for (int b = 0; b < (1 << n); ++b) {
        bool ok = true;

        for (int i = 0; i < n; ++i) {
            if (((b >> i) & 1) == 0) continue;

            for (int j = 0; j < n; ++j) {
                int y = ((b >> j) & 1);
                if (xss[i][j] >= 0 && xss[i][j] != y) {
                    ok = false;
                }
            }
        }

        if (ok) {
            ans = std::max(ans, __builtin_popcount(b));
        }
    }

    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9+7 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
void solve(){
    ll n ;
    cin >> n ;
    if(n==2){
        cout << 1 ;
        return ;
    }
    ll ans = 2 ;
//    ll ans1 = 0 ;
//    for( int i = 2 ; i <= n ; i++){
//        ll x = n ;
//        while(x%i==0){
//            x/=i;
//        }
//        x%=i;
//        if(x==1) cout << ans1++;
//    }
    for( ll i = 2 ; i*i <=  n ; i++){
        if(n%i==0){
            ll x = n ;
            while(x%i==0){
                    x/=i;
            }
            x%=i;
            if(x==1)  ans++;
        }
    }
    for( ll i = 2 ; i*i <=  n-1 ; i++){
        if( (n-1)%i==0){
            ans++;
            if((n-1)/i != i)
                ans++;
        }
    }
    cout << ans << "\n" ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t ;
    t = 1 ;

    //cin >> t ;
    while(t--){
        solve( );
    }
}
//   n-1=x*f


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

int main(){
    int N;
    cin >> N ; 
    vector<long long> A(N);    
    rep(i,N) cin >> A[i]; 
    sort(A.begin(),A.end(),greater<long long>()); 
    long long ans = A[0] ; 
    int times = (N - 2) / 2 ; 
    rep(i,times) ans +=  (2 * A[i + 1 ]); 
    if(N % 2 == 0 ){
        cout << ans << endl ;
    }
    else{
        cout << ans + A[times + 1 ] << endl; 
    }

   
}

Measured memory_bytes: 4764
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    cin >> n;
    ll A[200001];
    ll left = 0, right = 0;
    for(int i=0;i<n;i++){
        cin >> A[i];
        right += A[i];
    }
    ll min = right;
    for(int i=0;i<n;i++){
        if(min > labs(right-left)){
            min = labs(right-left);
        }
        left += A[i];
        right -= A[i];
    }
    cout << min << endl;
}


Measured memory_bytes: 1792
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int A = nextInt();
        int B = nextInt();

        for(int i=1; i<=1009; i++){
            if((int)(i*0.08) == A && (int)(i*0.1) == B){
                println(i);
                return;
            }
        }
        println(-1);
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);


int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int n, bool visited[nmax]) {
	bool all_visited = true;
	for (int i = 0;i < n;++i) {
		if (visited[i] == false)all_visited = false;
	}
	if (all_visited) {
		return 1;
	}
	int ret = 0;
	rep(i, n) {
		if (graph[v][i] == false)continue;
		if (visited[i])continue;
		visited[i] = true;
		ret += dfs(i, n, visited);
		visited[i] = false;
	}
	return ret;
}

int main() {
	int n, m;
	cin >> n >> m;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		graph[a - 1][b - 1] = graph[b - 1][a - 1] = true;
	}
	bool visited[nmax];
	rep(i, n) {
		visited[i] = false;
	}
	visited[0] = true;
	cout << dfs(0, n, visited) << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Apr  4 21:17:14 2020

@author: liang
"""

N, K = map(int,input().split())

if N > K :
    N = N%K
ans = N

    
while(min(ans,abs(ans-K)) != ans):
    ans = abs(ans-K)
    

print(ans)
 

Measured memory_bytes: 3060
main=do
  [h,w]<-map read.words<$>getLine
  s<-lines<$>getContents
  f h w 0 0 s
f h w i j s=
  putStr(if s!!i!!j=='#'then"#"else show(sum[if s!!tx!!ty=='#'then 1 else 0|rx<-[-1..1],let tx=i+rx,ry<-[-1..1],let ty=j+ry,tx>=0&&ty>=0&&tx<h&&ty<w]))>>
  if j+1<w then f h w i (j+1) s else
    putStrLn"">>if i+1<h then f h w (i+1) 0 s else return()

Measured memory_bytes: 1020
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=605;
int vis[N][N],n,a,b;
void solve(R int x){
	R int d=0;
//	printf("qwq %d %d\n",x,d);
	while(!(x&3))++d,x>>=2;
//	printf("QAQ %d %d\n",x,d);
	if(x&1){
		fp(i,0,n-1)fp(j,0,n-1)if(((i>>d)+(j>>d))&1)vis[i][j]=1;
	}
	else{
		fp(i,0,n-1)if((i>>d)&1)fp(j,0,n-1)vis[i][j]=1;
	}
}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d%d",&n,&a,&b),n<<=1;
	solve(a),solve(b);
	int cnt=0;
	fp(i,0,n-1){
		fp(j,0,n-1)if(!vis[i][j]){
			printf("%d %d\n",i,j),++cnt;
			if(cnt==(n*n)>>2)return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 2304
#include<iostream>

using namespace std;

int main()
{
	int i, j;
	int a, b;

	while (true)
	{
		cin >> a >> b;
		if (a == 0 && b == 0) break;
		for (i = 0; i < a; i++)
		{
			for (j = 0; j < b; j++)
			{
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
F=->z,c{f=G[c].size==2?1:0;r=[0,c];G[c].map{|e|e!=z&&(x,y=F[c,e];r=[r,[x+f,y]].max)};r}
G=(0..gets.to_i).map{[]}
$<.map{|e|a,b=e.split.map &:to_i;G[a]<<b;G[b]<<a}
p F[-1,F[-1,1][1]][0]+G.count{|e|e.size==1}

Measured memory_bytes: 15740
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================
//using系

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ld = long double;
using qul = queue<ll>;
using pql = priority_queue<ll>;

// ========================================================================
//define系

//#define int long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)

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


ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll mch(ll n) {
	if (n == 1) return 1;
	else return n * mch(n - 1);
}
//1から整数nまでの階乗を出す(INFで割っていない)
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定
ll modpow(ll a, ll n, ll mod) {
	ll hi = 1;
	while (n > 0) {
		if (n & 1) hi = hi * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return hi;
}
//いろいろやります（ただの前座）
ll mg(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}
//割り算の10^9+7等対策で逆元を出します 




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


/*signed*/int main() {
	ll n; cin >> n;
	ll ans = 0;
	if (n == 1) cout << 1 << endl;
	else {
		if (n == 2) cout << 2 << endl;
		else {
			for (int i = 1; i < n; i++) {
				if (i * (i + 1) / 2 >= n) {
					ans = i;
					break;
				}
			}
			cout << ans << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef unsigned long long lu;
typedef pair<int, int> pi;
typedef long long ll;
typedef long double lf;
const ll mod = 1e9 + 7;
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while (b <= a)
    {
        b *= 2;
        k--;
    }
    while (c <= b)
    {
        c *= 2;
        k--;
    }
    cout << (k >= 0 ? "Yes" : "No") << "\n";
    return 0;
}

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

int main()
{
    string a, b;
    cin >> a >> b;
    a += b;

    int x = stoi(a);
    int y = pow(x, 0.5);

    if (x == y * y)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
package main

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

type Pos struct {
	X int
	Y int
	l int
}

func main() {
	sc := NewScanner()
	H, W := sc.NextInt(), sc.NextInt()
	grid := make([][]byte, H)
	check := make([][]bool, H)
	block := 0
	for i := 0; i < H; i++ {
		grid[i] = []byte(sc.NextLine())
		check[i] = make([]bool, W)
		for j := 0; j < W; j++ {
			if grid[i][j] == '#' {
				block++
			}
		}
	}

	queue := []Pos{}
	queue = append(queue, Pos{0, 0, 0})
	check[0][0] = true
	current := 0
	for current < len(queue) {
		c := queue[current]
		for i := -1; i <= 1; i++ {
			for j := -1; j <= 1; j++ {
				x := c.X + i
				y := c.Y + j
				l := c.l + 1
				if abs(i)+abs(j) != 1 {
					continue
				}
				if 0 <= x && x < W && 0 <= y && y < H {
				} else {
					continue
				}
				if check[y][x] {
					continue
				}
				if grid[y][x] == '#' {
					continue
				}
				if y == H-1 && x == W-1 {
					fmt.Println(H*W - l - 1 - block)
					return
				}
				queue = append(queue, Pos{x, y, l})
				check[y][x] = true
			}
		}
		current++
	}
	fmt.Println(-1)

}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

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: 896
#! /usr/bin/env ruby
require 'bigdecimal'

N, K = gets.chop.split.map(&:to_i)

@sum = 0

(1..N).to_a.each do |i|
  now = i
  probability = Rational(1, N)
  while now < K do
    now *= 2
    probability *= Rational(1, 2)
  end
  @sum += probability
end

puts @sum.to_f

Measured memory_bytes: 2684
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e10;
const double EPS=1e-8;

int main(){
	ll n;
	cin>>n;
	vector<ll> dam;
	for(ll i1=0;i1<n;i1++){
		ll temp;
		cin>>temp;
		dam.push_back(temp);
	}
	ll sum = accumulate(dam.begin(),dam.end(),0LL);

	ll other_sum=0;
	for(ll i1=1;i1<n;i1+=2){
		other_sum += dam[i1];
	}
	ll mountain = sum-2*other_sum;
	cout<<mountain<<" ";
	for(ll i1=0;i1<n-1;i1++){
		mountain = 2*dam[i1]-mountain;
		cout<<mountain<<" ";
	}
	cout<<endl;
}


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

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    int tmp;
    while (y) {
        tmp = y;
        y = x % y;
        x = tmp;
    }

    return x;
}

int n, k;
vector<int> a;

int main() {
    cin >> n >> k;
    a.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

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

    if (k > a[0]) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    int g = a[0];
    for (int i = 1; i < n; ++i) {
        g = gcd(g, a[i]);
    }

    if (k % g == 0) {
        cout << "POSSIBLE" << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
/// Author: Sarfaraz Alam
# include <bits/stdc++.h>
# define pb push_back
# define ll long long

# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG
typedef unsigned long long int ull;
using namespace std;
#include<string>
#include<cmath>
const int N = 1e5 + 7;
const int mod = 1e9 + 7;


int main()
{
    speed;
    #ifdef DEBUGfd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG

    //Code begins
    int n, k;
    cin>>n>>k;
    //vector<int> a;
    int a[n];
    for(int i = 0; i<n; i++)
    cin>>a[i];


    sort(a, a+n, greater<int>());
    ull sum = 0;
    for(int i = 0; i<k; i++)
    sum += a[i];

    cout<<sum<<endl;






    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s, ans string
	fmt.Scan(&s)
	for _, letter := range s {
		switch letter {
		case '0':
			ans += "0"
		case '1':
			ans += "1"
		case 'B':
			if ans != "" {
				trim := ans[:len(ans)-1]
				ans = trim
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
from sys import setrecursionlimit as SRL, stdin

SRL(10 ** 7)
rd = stdin.readline
rrd = lambda: map(int, rd().strip().split())

n, m = rrd()

g1 = [[] for _i in range(605)]
g2 = [[] for _i in range(605)]
e = [0] * 605
for i in range(m):
    x, y = rrd()
    g1[x].append(y)
    g2[y].append(x)

p = [0] * 605
p[1] = 1
for i in range(1, n + 1):
    for j in g1[i]:
        p[j] += p[i]/len(g1[i])

for i in range(n, 0, -1):
    for j in g1[i]:
        e[i] += (e[j] + 1) / len(g1[i])
ans = e[1]

for i in range(n, 0, -1):
    ne = 0
    if len(g1[i]) == 1:
        continue
    for j in g1[i]:
        ne += (e[j] + 1) / (len(g1[i]) - 1)

    for j in g1[i]:
        dis = ne - (e[j] + 1) / (len(g1[i]) - 1) - e[i]
        ans = min(ans,e[1] + p[i]*dis)

print(ans)


Measured memory_bytes: 62940
import numpy as np
A = [list(map(int, input().split()))]
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
A = np.array(A)
result = A
for _ in range(int(input())):
    result[A == int(input())] = 0
ans = "No"
for i in range(3):
    if sum(result[i, :] == 0) == 3:
        ans = "Yes"
for j in range(3):
    if sum(result[:, j] == 0) == 3:
        ans = "Yes"
if sum([result[0, 0], result[1, 1], result[2, 2]]) == 0:
    ans = "Yes"
if sum([result[2, 0], result[1, 1], result[0, 2]]) == 0:
    ans = "Yes"
print(ans)

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

int main(){
	int N,W,w[100],v[100];
	cin >> N >> W;
	for(int i = 0; i < N; i++){
		cin >> v[i] >> w[i];
	}
	int DP[101][10001];
    	for(int j = 0;j <= W; j++){
       	DP[0][j] = 0;
	}

    	for(int i = 1;i <= N; i++){
		for(int j = 0; j <= W; j++){
			if(j < w[i-1]){
				DP[i][j] = DP[i-1][j];
			}else{
				if(DP[i-1][j] > DP[i-1][j-w[i-1]] + v[i-1]){
					DP[i][j] = DP[i-1][j];
				}else{
					DP[i][j] = DP[i-1][j-w[i-1]] + v[i-1];
				}
			}
		}
	}

	cout << DP[N][W] << endl;

	return 0;
}


Measured memory_bytes: 5104
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	for i := 0; i <= a*b; i++ {
		if (i*a-c)%b == 0 {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,a[102],k=0,l=0,cnt=0,x,n;
    map<int,int>m;
     cin>>n;
     for(i=0;i<n;i++){cin>>a[i];}
     sort(a,a+n);
     for(i=0;i<n-1;i++){l+=a[i];}
     l+=a[n-1]/2;
     cout<<l<<endl;


}



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

using namespace std;

int CarryCheese(double, double, double);

int main(){
  int i, n, hole, result, data[3];

  while(1){
    for(i=0; i<3; ++i)
      cin >> data[i];
    if(data[0] == 0 && data[1] == 0 && data[2] == 0) break;

    sort(data, data+3);

    cin >> n;
    for(i=0; i<n; ++i){
      cin >> hole;
      result = CarryCheese(((double)data[0])/2, ((double)data[1])/2, (double)hole);
      if(result == 1)
	cout << "OK" << endl;
      else
	cout << "NA" << endl;
    }
  }

  return 0;
}


int CarryCheese(double x, double y, double h){
  if(x >= h)
    return 0;
  else if(y < sqrt(h*h - x*x))
    return 1;
  else
    return 0;
}

Measured memory_bytes: 0
#![allow(unused_mut, unused_variables, unused_assignments)]

macro_rules! input {
    ($($s:tt,$r:tt),*) => {
        let stdin = std::io::stdin();
        let mut buf = String::new();
        stdin.read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        $(let $s:$r = iter.next().unwrap().parse().unwrap();)*
    };
}

fn gcd(a:u64, b:u64) -> u64 {
    if 0 == b {return a;}
    return gcd(b, a % b);
}

fn lcm(a:u64, b:u64) -> u64 {
    return a / gcd(a, b) * b;
}

fn solve(n:u64, c:u64, d:u64) -> u64 {
    return n / c + n / d - n / lcm(c, d);
}

fn main() {
    input!(a,u64, b,u64, c,u64, d,u64);
    println!("{}", b - (a - 1) - (solve(b, c, d) - solve(a - 1, c, d)));
}


Measured memory_bytes: 4352
use text_io::*;
use std::collections::*;
use std::process::exit;

fn main() {
    let mut a:String = read!();
    let mut b:String = read!();
    let mut va:Vec<char> = a.chars().collect();
    let mut vb:Vec<char> = b.chars().collect();
    let mut sum:usize = 0;
    for i in 0..3 {
        if va[i] == vb[i] {
            sum+=1;
        }
    }
    println!("{}",sum);
}

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

const int MAXN=300005;
int X[MAXN],Y[MAXN];
struct square
{
	int x,y;
}sq[MAXN];

int main()
{
	//1.输入 
	int H,W,M;
	scanf("%d%d%d",&H,&W,&M);
	//2.统计目标 
	int max_x=0,max_y=0;
	int u,v;
	for(int i=1;i<=M;++i)
	{
		scanf("%d%d",&u,&v);
		++X[u];++Y[v];
		sq[i].x=u;
		sq[i].y=v;
	}
	//3.搜索最大目标数 
	for(int i=1;i<=H;++i)
		if(X[i]>max_x) max_x=X[i];	
	for(int i=1;i<=W;++i)
		if(Y[i]>max_y) max_y=Y[i];
	//4.找出最大行数 
	int x_=0,y_=0;
	for(int i=1;i<=H;++i)
		if(X[i]==max_x) x_++;
	for(int i=1;i<=W;i++)
		if(Y[i]==max_y) y_++;
	int cnt=0;
	for(int i=1;i<=M;++i)
		if(X[sq[i].x]==max_x && Y[sq[i].y]==max_y) ++cnt;
	if(cnt==x_*y_) printf("%d",max_x+max_y-1);
	else printf("%d",max_x+max_y);	
	return 0;   
 } 

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

long b;
string s,ans;

bool c(string x) {
  if(x.size()>b) return false;
  for(long i=1;i<=x.size();i++) {
    if(s[b-i]!=x[x.size()-i]) return false;
  }
  return true;
}
 
int main() {
  cin >> s;
  b=s.size();
  while(true) {
    if(b==0) {
      ans="YES";
      break;
    } else if(c("dream")) {
      b-=5;
    } else if(c("dreamer")) {
      b-=7;
    } else if(c("erase")) {
      b-=5;
    } else if(c("eraser")) {
      b-=6;
    } else {
      ans="NO";
      break;
    }
  }
  
  cout << ans << endl;
}

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

int solve(vector<int> &a)
{
    int n = a.size();
    vector<int> dp(n);
    dp[0] = dp[1] = 0;
    dp[2] = dp[1] + abs(a[2]-a[1]);
    for(int i=3; i<=n; i++){
        dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]), dp[i-2] + abs(a[i]-a[i-2]));
    }

    return  dp[n-1];
}


int main()
{
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i=1; i<=n; i++) cin >> a[i];
    cout << solve(a) << '\n';
    return 0;
}

Measured memory_bytes: 3988
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

using namespace std;
using ll=long long;
int res=0;

void dfs(vector<vector<int>> adj,int index,vector<bool> th){
  th[index]=true;
  for(int i=0;i<adj[index].size();i++){
    if(th[adj[index][i]])continue;
    dfs(adj,adj[index][i],th);
  }
  bool b=true;
  for(int i=0;i<th.size();i++)
    b&=th[i];
  if(b)res++;
  th[index]=false;
}

void solve(){
  int num,m;
  cin >> num >> m;
  vector<vector<int>> adj(num,vector<int>(num));
  while(m--){
    int a,b;
    cin >> a >> b;
    a--;b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  vector<bool> th(num);
  dfs(adj,0,th);
  cout << res << endl;
}

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


Measured memory_bytes: 256
n=list(map(str,input()))
# 隙間の数
cnt = len(n) - 1
for i in range(2**cnt):
  op = ['-'] * cnt
  for j in range(cnt):
    if((i>>j) & 1):
      op[cnt - 1 - j] = '+'
  formula = ''
  for p_n, p_o in zip(n, op+['']):
    # n->p_n: 1
    # op+['']->p_o: +, +, +, ''
    formula += (p_n + p_o)
  if eval(formula) == 7:
    print(formula + '=7')
    break

Measured memory_bytes: 8964
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<vector>
#define N 210000
#define ll long long
#define ls (now<<1)
#define rs ((now<<1)|1)
#define RG register
using namespace std;
inline int read(){
    RG int x=0,o=1; RG char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=((x<<3)+(x<<1))+ch-'0',ch=getchar();
    return x*o;
}

inline int Gcd(int x,int y) { while(y^=x^=y^=x%=y); return x; }
int a[N];

int main(){
	int n=read(),x=read(),now;
	for(RG int i=1;i<=n;++i) a[i]=abs(read()-x);
	if(n==1) { cout<<a[1]; return 0 ; }
	now=Gcd(a[1],a[2]);
	for(RG int i=3;i<=n;++i) now=Gcd(now,a[i]);
	cout<<now;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main(){
  int a,b,h,m;
  cin >> a >> b >> h >> m;

  double hh = (double)(60*h+m) / 720 * 2*PI;
  double mm = (double)m / 60 * 2*PI;
  double rr = abs(hh - mm);
  double ans = a*a + b*b - 2*a*b*cos(rr);
  ans = sqrt(ans);
  printf("%.15f\n", ans);
  return 0;
}


Measured memory_bytes: 4176
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	char aa[2001];
	int a[2002][2002];
	int lx[2002][2002];
	int zx[2002][2002];
	int n, m, q;
	int x1, x2, y1, y2;
	int fa, fl, fz;
	scanf("%d %d %d", &n, &m, &q);
	for (int i = 0; i < 2002; i++){
		for (int j = 0; j < 2002; j++){
			a[i][j] = 0;
			lx[i][j] = 0;
			zx[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++){
		scanf("%s",aa);
		for (int j = 0; j < m; j++){
			a[i+1][j+1] = aa[j] - 48;
			if (j > 0){
				if (a[i+1][j+1] == 1 && a[i+1][j] == 1)lx[i+2][j+1] = 1;
				else lx[i+2][j+1] = 0;
			}
			if (i > 0){
				if (a[i+1][j+1] == 1 && a[i][j+1] == 1)zx[i+1][j+2] = 1;
				else zx[i+1][j+2] = 0;
			}
		}
	}
	for (int i = 1; i <= n; i++){
		for (int j = 2; j <= m; j++){
			a[i][j] = a[i][j - 1] + a[i][j];
			lx[i+1][j+1] = lx[i+1][j] + lx[i+1][j+1];
			zx[i+1][j+1] = zx[i+1][j] + zx[i+1][j+1];
		}
	}
	for (int i = 1; i <= m; i++){
		for (int j = 2; j <= n; j++){
			a[j][i] = a[j-1][i] + a[j][i];
			lx[j+1][i+1] = lx[j][i+1] + lx[j+1][i+1];
			zx[j+1][i+1] = zx[j][i+1] + zx[j+1][i+1];
		}
	}

	for (int qq = 0; qq < q; qq++){
		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
		fa = a[x2][y2] + a[x1-1][y1-1]-a[x2][y1-1]-a[x1-1][y2];
		fl = lx[x2+1][y2] + lx[x1][y1]-lx[x1][y2]-lx[x2+1][y1];
		fz = zx[x2][y2+1] + zx[x1][y1] - zx[x2][y1] - zx[x1][y2+1];
		printf("%d\n", fa - fl - fz);
	}

	return 0;
}

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

using namespace std;
int N, K;

int main(){
  cin >> N >> K;
  vector<long long int> V(N, 0LL);
  for(int i = 0; i < N; i++) cin >> V[i];
  
  
  int lowerbound = -1;
  for(int i = 0; i < N; i++){
    if(V[i] >= 0LL){
      lowerbound = i;
      break;
    }
  }
  long long int ans = 0;
  if(lowerbound == -1){
    ans = abs(V[N-K]);
  }else if(lowerbound == 0){
    ans = abs(V[K-1]);
  }else{
    ans = 1000000000LL;
    for(int i = 0; i <= K; i++){
      //lowerbound + i迄行っておりかえした場合の距離
      if(i + lowerbound >= N||lowerbound - (K - i) + 1 < 0) continue;
      ans = min(abs(V[i + lowerbound]) * 2 + abs(V[lowerbound - (K - i) + 1]),ans);
    }
    for(int i = 0; i <= K; i++){
      //lowerbound - i迄行っておりかえした場合の距離
      if(lowerbound + (K - i) >= N||lowerbound - i + 1< 0) continue;
      ans = min(abs(V[lowerbound - i + 1]) * 2 + abs(V[lowerbound + (K - i)]),ans);
    }
  }
  cout << ans;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

const int N=1e5+5;

typedef long long LL;

int n,a[N];

bool ans;

int gcd(int x,int y)
{
	return (!y)?x:gcd(y,x%y);
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i,p,s;;)
	{
		for (p=s=0,i=1;i<=n;i++) if (a[i]&1) s++;else p^=1;
		if (p)
		{
			ans^=1; break;
		}
		if (s>1) break;
		for (i=1;i<=n;i++) if (a[i]&1) break;
		if (a[i]==1) break;
		a[i]--;
		s=a[1];
		for (i=2;i<=n;i++) s=gcd(s,a[i]);
		for (i=1;i<=n;i++) a[i]/=s;
		ans^=1;
	}
	if  (ans) printf("First");else printf("Second");
	return 0;
}

Measured memory_bytes: 640
SEQUENCE_LEN_MIN = 2
SEQUENCE_LEN_MAX = 200000
NUMERIC_MIN = 1
NUMERIC_MAX = 200000
 
 
class NumericInfo:
    def __init__(self):
        self.index = - 1
        self.value = NUMERIC_MIN - 1
 
    def update(self, idx, val):
        self.index = idx
        self.value = val
 
    def copy(self, info):
        self.update(info.index, info.value)
 
 
class SequenceProcessor:
    def __init__(self, sequence):
        self.sequence_length = len(sequence)
        self.first_largest_num_info = NumericInfo()
        self.second_largest_num_info = NumericInfo()
        self._process(sequence)
 
    def _process(self, sequence):
        for i, num in enumerate(sequence):
            if self.first_largest_num_info.value < num:
                self.second_largest_num_info.copy(self.first_largest_num_info)
                self.first_largest_num_info.update(i, num)
            elif self.second_largest_num_info.value < num:
                self.second_largest_num_info.update(i, num)
 
    def _max_value(self, idx):
        if idx == self.first_largest_num_info.index:
            return self.second_largest_num_info.value
        else:
            return self.first_largest_num_info.value
 
    def all_max_value(self):
        for i in range(self.sequence_length):
            yield self._max_value(i)
 
 
def _validate_sequence_length(s):
    r = int(s)
 
 
def get_sequence_length_from_stdin():
    s = input()
    s = s.strip()
    return int(s)
 
 
def _validate_numeric(s):
    r = int(s)
 
 
def get_sequence_from_stdin(length):
    result = []
    for i in range(1, length+1):
        while True:
            n = input()
            try:
                result.append(int(n))
                break
            except ValueError:
                continue
    return result
 
 
def main():
    seq_len = get_sequence_length_from_stdin()
    sequence = get_sequence_from_stdin(seq_len)
    seq_processor = SequenceProcessor(sequence)
    for num in seq_processor.all_max_value():
        print(num)
 
 
if __name__ == '__main__':
    main()

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

int isprime(int x){
    if(x == 2) return 1;
    if(x < 2 || !(x % 2)) return 0;
    for(int j = 3; j <= sqrt(x); j += 2){
        if(x % j == 0) return 0;
    }
    return 1;
}

int main(){
    int n;
    cin >> n;
    int x;
    int o = 0;
    for(int i=0; i<n; ++i){
        cin >> x;
        o += isprime(x);
    }
    cout << o << endl;
    return 0;
}




Measured memory_bytes: 3060
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	final int LEN = 0;
	
	void doIt() {
		String s = sc.next();
		String[] d = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
		for(int i = 0; i < 7; i++) {
			if(s.equals(d[i])) {
				System.out.println(7 - i);
				return;
			}
		}
		
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#define int long long
using namespace std;

signed main(){
  int A,B,C,D;
  int N[100]={};
  int count=0;
  cin >> A >> B >> C >> D;
  for(int i=A;i<100;i++)  N[i]++;
  for(int i=B;i<100;i++)  N[i]--;
  for(int i=C;i<100;i++)  N[i]++;
  for(int i=D;i<100;i++)  N[i]--;
  for(int i=0;i<100;i++)  if(N[i]==2)count++;
  cout << count;
}

Measured memory_bytes: 256
n=int(input())
s=input()
dp=[n*[0]for _ in range(n)]
for i in range(n):
  if s[i]==s[0]:
    dp[i][0]=dp[0][i]=1
for i in range(1,n):
  for j in range(1,n):
    if s[i]==s[j]:
      dp[i][j]=dp[i-1][j-1]+1
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    if i<j-dp[i][j]+1:ans=max(ans,dp[i][j])
print(ans)

Measured memory_bytes: 230024
/*
    AUTHOR : TANMAY SINHA
    INORMATION TECHNOLOGY
    BIT MESRA ,RANCHI
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define pb(x) push_back(x)
#define eb(x) emplace_back()
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define rep(j,L,R) for(j=L;j<R;j++)
#define per(i,L,R) for(i=L;i>= R;i--)
#define all(con) (con).begin(),(con).end()
#define fi first
#define se second
#define foreach(iter,con) for(auto iter=(con).begin(); iter!=(con).end(); iter++)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
const ll INF = 1e18l+10,N = 1e5+10,MAX = 1e6+5;
#define sq(X) ((X)*(X))

int main()
{
    SPEED
    ll n,m;
    cin>>n>>m;
    cout<<lcm(n,m)<<"\n";
}






Measured memory_bytes: 256
from collections import deque

n, q = list(map(int, input().split()))
S = deque()
[S.append([]) for _ in range(n)]

for i in range(q):
    query = list(map(int, input().split()))
    t = query[1]

    # push
    if query[0] == 0:
        S[t].append(query[2])

    # top
    elif query[0] == 1:
        if S[t]:
            print(S[t][-1])

    # pop
    else:
        if S[t]:
            S[t].pop()


Measured memory_bytes: 14080
#include <cstring>
#include <cstdlib>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define ABS(a) ((a)<0?(-(a)):(a))
#define CS while(cases())
#define I(n) int n = gi()
#define II(n) n = gi()
#define L(n) ll n = gli()
#define LL(n) n = gli()
#define F(i, n) for (int i = 0; i < n; i++)
#define Fa(n, a) for (int i = 0; i < n; i++) a[i] = gi()
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

template<class T>
T gcd(T a, T b) {
    return (b == 0 ? a : gcd(b, a%b));
}

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int cases() {
    static int t = gi();
    return t--;
}

#define MD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll s = 0;
    map<int, int> m;
    I(n);
    F(i, n) {
        I(x);
        m[x]++;
        s += x;
    }
    I(q);
    F(i, q) {
        I(b); I(c);
        int h = m[b]; m.erase(b);
        s += ll(h)*ll(c-b);
        m[c] += h;
        cout << s << endl;
    }

    return 0;
}


Measured memory_bytes: 6652
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {

	var a []string

	for sc.Scan() {
		b := sc.Text()

		if "0" == b {
			break
		}

		a = append(a, b)
	}

	for _, v := range a {

		c := 0

		for _, v2 := range v {
			d, _ := strconv.Atoi(string(v2))
			c += d
		}
		fmt.Println(c)
	}

}



Measured memory_bytes: 1092
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;
int main(){

string x;

cin >> x;

int max = 0;

int y = 0;

for( int i = 0 ; i < x.length() ; i++ ){

	if(x[i] == 'T'){
		y++; y++;
		if(max < y){
			max=max+2;
		}
	}else{
		y--; y--;
	}
	
}


cout << max;

return 0;

}

Measured memory_bytes: 1156
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define ull unsigned long long
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;
const int MOD=1e9+7;

int main()
{
    int k;
    string s;
    in k>>s;
    string ans="";
    if(s.size()<=k)cout<<s<<endl;
    else {
        for(int i=0;i<k;i++)
        {
            ans+=s[i];
        }
    cout<<ans<<"..."<<endl;

    }
}


Measured memory_bytes: 3632