akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
#define USE_MATH_DEFINES
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

int nums[100];

int main(){
	int n;
	int c, pos;
	bool turn;
	while(cin >> n && n){
		turn = true;
		pos = 0;
		c = 32;
		rep(i, n)cin >> nums[i];
		while(c > 0){
			if(turn){
				c -= (c-1)%5;
			}else{
				c -= nums[pos];
				pos = (pos+1)%n;
			}
			cout << max(c, 0) << endl;
			turn = !turn;
		}
	}
	return 0;
}

Measured memory_bytes: 0
N,M= map(int,input().split())
P = [0 for _ in range(N+1)]
S = [0 for _ in range(N+1)]
for i in range(M):
    p, s = input().split()
    if s == "WA" and S[int(p)] != 1:P[int(p)] += 1
    if s == "AC":S[int(p)] = 1
for i in range(N+1):
    if S[i] == 0:P[i] = 0
print(sum(S),sum(P))

Measured memory_bytes: 4760
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	k := scanInt()
	a := scanInts(n)

	b := make([]int, 60)

	for i := 0; i < n; i++ {
		for j := 0; j < 50; j++ {
			if a[i]>>uint(j)&1 == 1 {
				b[j]++
			}
		}
	}

	ans := 0
	f := false
	for i := 50; i >= 0; i-- {
		num := 1 << uint(i)
		if num > k {
			ans += b[i] * num
		} else {
			if !f {
				if k>>uint(i)&1 == 0 {
					ans += b[i] * num
				} else {
					if n-b[i] < b[i] {
						f = true
						ans += b[i] * num
					} else {
						ans += (n - b[i]) * num
					}
				}
			} else {
				ans += max(n-b[i], b[i]) * num
			}
		}
		// debug(num, b[i], ans)
	}
	fmt.Fprintln(wr, ans)

}


Measured memory_bytes: 3072
def main():
    N = int(input())
    tasks = []
    for i in range(N):
        tasks.append(list(map(int, input().split())))
    tasks.sort(key=lambda x: x[1])
    t = 0
    for task in tasks:
        t += task[0]
        if t > task[1]:
            print('No')
            return
    print('Yes')
if __name__ == "__main__":
    main()


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int Nmax=114514;
bool vis[Nmax];
int t[Nmax];
vi graph[Nmax];

bool dfs(int v,int d){
	if(vis[v])return t[v]==d;
	vis[v]=true;
	t[v]=d;
	bool res=true;
	for(auto to:graph[v])
		res&=dfs(to,d^1);
	return res;
}

signed main(){
	int n=read(),m=read();
	REP(i,m){
		int u=read()-1,v=read()-1;
		graph[u].PB(v);
		graph[v].PB(u);
	}
	int x=0,y=0,z=0;
	REP(i,n)if(!vis[i]){
		if(graph[i].empty())
			z++;
		else if(dfs(i,0))
			x++;
		else
			y++;
	}
	cout<<x*x*2+x*y*2+y*y+z*n*2-z*z<<endl;
}


Measured memory_bytes: 13312
N, M = gets.split.map(&:to_i)

K = []
S = []
M.times do
  k, *s = gets.split.map(&:to_i)
  K << k
  S << s
end
P = gets.split.map(&:to_i)

ans = 0
# [0, 1<<N)
for i in 0...(1<<N)
  all_swithces_are_on = true
  for j in 0...M
    number_of_switches = K[j]
    on_switches = 0
    for k in 0...number_of_switches
      if (i >> (S[j][k]-1) & 1) == 1
        on_switches += 1
      end
    end

    # puts "i: #{i} switch: #{j} count: #{on_switches} pj: #{P[j]} satisfied: #{on_switches % 2 == P[j]}"

    if on_switches % 2 != P[j]
      all_swithces_are_on = false
      break
    end
  end

  if all_swithces_are_on
    ans += 1
  end
end

puts ans


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp(a,b) make_pair(a,b)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

int main(){
    ll N; cin>>N;
  vector<ll> a(N+1);
  rep1(i,N) cin>>a[i];
  ll ans=a[1];
  for(ll i=2;i<=N;i++){
  	ans=lcm(a[i],ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<" "
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 100000000000000000
#define sp << " " <<
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);

int main()
{
    fast;
    ll n;
    cin >> n;
    ld a[n+1],dp[n+1]={0};
    dp[0]=1;
    ld x,ans=0;
    fr(i,1,n+1)
    {
        cin >> x;
        fr1(j,i,1)
            dp[j]=dp[j]*(1-x)+dp[j-1]*x;
        dp[0]*=(1-x);
    }
    fr(i,(n+1)/2,n+1)
        ans+=dp[i];
    fixd(10);
    cout << ans;
}

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

struct mdata {
    int student;
    double weight;
    double height;
    double bmi;
};

mdata bmi(mdata buff)
{
    buff.bmi = buff.weight / (buff.height * buff.height);
    return buff;
}

int main()
{
    vector<mdata> data;
    vector<mdata>::iterator it;
    mdata buff;
    char ch;
    while(cin >> buff.student >> ch >> buff.weight >> ch >> buff.height)
        data.push_back(buff);
    transform(data.begin(),data.end(),data.begin(),bmi);
    for(it = data.begin(); it != data.end(); it++)
        if((*it).bmi >= 25) cout << (*it).student << endl;

    return EXIT_SUCCESS;
}

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

typedef int ll;

#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define endl '\n'

typedef pair<int,int>pii;
typedef pair<int,pair<int,int> > piii;

const int mod=1e9+7;

int POWER[65];
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
int inv(int x) {return power(x,mod-2);}

void precompute() {
    POWER[0]=1;
    for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}

int num[30];

ll main() {
    // freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);

    std:ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    string s;
    cin>>s;

    int su=0;
    for(int i=0 ; i<sz(s) ; i++) {
        num[s[i]-'a']++;
    }
    for (int i=0 ; i<26 ; i++) {
        su+=((num[i]*(num[i]+1))/2);
    }

    int ret=(sz(s)*(sz(s)+1))/2+1;
    cout<<ret-su<<endl;
}

Measured memory_bytes: 720
object Main extends App {
  val n: Int = io.StdIn.readLine().toInt
  val arr: Array[Int] = io.StdIn.readLine().split(" ") map(_.toInt)

  val maxVal: Int = 10000
  val count: Array[Int] = Array.fill(maxVal+1)(0)
  val result: Array[Int] = Array.fill(n)(0)

  for (i <- arr) count(i) += 1
  for (i <- 1 until count.length) count(i) += count(i-1)

  for (i <- n-1 to 0 by -1) {
    result(count(arr(i))-1) = arr(i)
    count(arr(i)) -= 1
  }

  println(result.mkString(" "))
}

Measured memory_bytes: 480144
a,b,c = map(int,input().split(" "))
if(c>a+b):
  print((a+b)+1+b)#毒入りクッキーの食べられる枚数a+bと最後に食べる数+1とBのクッキーの枚数
elif(c==a+b):
  print(c+b)
else:
  print(c+b)
  
 
  
  


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int>> construct(vector<int> nodes)
{
    int n = nodes.size();
    vector<pair<int,int>> ret;
    if(n == 3)
    {
        ret.push_back({nodes[0],nodes[1]});
        ret.push_back({nodes[0],nodes[2]});
        return ret;
    }
    if(n == 4)
    {
        ret.push_back({nodes[0],nodes[1]});
        ret.push_back({nodes[0],nodes[2]});
        ret.push_back({nodes[1],nodes[3]});
        ret.push_back({nodes[2],nodes[3]});
        return ret;
    }
    if(n%2 == 1)
    {
        for(int i=1;i<n;++i)
            ret.push_back({nodes[0],nodes[i]});
        vector<int> next;
        for(int i=1;i<n;++i)
            next.push_back(nodes[i]);
        auto res = construct(next);
        for(auto p:res){
            ret.push_back(p);
        }
        return ret;
    }else{
        for(int i=1;i<n-1;++i)
            ret.push_back({nodes[0],nodes[i]}),ret.push_back({nodes[i],nodes[n-1]});
        vector<int> next;
        for(int i=1;i<n-1;++i)
            next.push_back(nodes[i]);
        auto res = construct(next);
        for(auto p:res){
            ret.push_back(p);
        }
        return ret;
    }
}
int main()
{
    int n;
    cin>>n;
    vector<int> nodes;
    for(int i=n-1;i>=0;--i){
        nodes.push_back(i+1);
    }
    auto res = construct(nodes);
    cout<<res.size()<<endl;
    for(auto p:res)
    {
        cout<<p.first<<" "<<p.second<<endl;
    }
}

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

typedef long long ll;

struct BIT{
    // 1-origin
    vector<int> v;
    int n;

    BIT(int _n):
        v(vector<int>(_n+1, 0)), n(_n) {}

    int sum(int i){
        int s = 0;
        while(i > 0){
            s += v[i];
            i -= lsb(i);
        }
        return s;
    }

    int sum(int l, int r){
        return sum(r) - sum(l-1);
    }

    void add(int i, int x){
        while(i <= n){
            v[i] += x;
            i += lsb(i);
        }
    }

    ll invNum(){
        ll ret = 0;
        for(int j = 0; j < n; j++){
            ret += j - sum(v[j]);
            add(v[j], 1);
        }
        return ret;
    }

private:
    // least significant bit
    int lsb(int i){
        return i & -i;
    }
};


int main(){
    int n, q;
    cin >> n >> q;

    BIT b(n);
    int op, x, y;
    for(int i = 0; i < q; i++){
        cin >> op >> x >> y;
        if(op == 0){
            b.add(x, y);
        }else if(op == 1){
            cout << b.sum(x, y) << endl;
        }
    }

    return 0;
}




Measured memory_bytes: 3100
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(){
    int n,d[101];
    int count=0,flag=0;
    scanf("%d",&n);

    for(int i=1;i<=n;i++){
        scanf("%d",&d[i]);
        flag=0;
        for(int j=1;j<=i-1;j++){
            if(d[j]==d[i]){
                flag=1;
                break;
            }
        }
        if(!flag)count++;
    }
    printf("%d",count);


    return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	cout << fixed << setprecision(10);
	int r;
	cin >> r;

	cout << 2 * PI * r << endl;
	return 0;
}


Measured memory_bytes: 3800
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MAX(a,b) (a>b?a:b)

int main()
{
    long long int i, n, p, ans;
    scanf("%lld %lld",&n, &p);
    long long start = (long long)( pow(p, (double)1.0/n) + 0.1 );
    for(ans=start; p % (long long)pow(ans,n) != 0; ans--);
    //if(n==1 && p!=1)ans--;
    //printf("start = %lld\n",start);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,x[110],maxi=0;
int ans=1e9;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&x[i]);
		maxi=max(maxi,x[i]);
	}
	for(int i=1;i<=maxi;i++) {
		int cnt=0;
		for(int j=1;j<=n;j++) {
			cnt+=(x[j]-i)*(x[j]-i);
		}
		ans=min(ans,cnt);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define m_p make_pair
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;


int32_t main(){
 	fastIO;
	int n;cin>>n;
	int sm=0;
	for(int i=1;i<=n;i++){
		if(i%3==0||i%5==0);
		else{
			sm+=i;
		}
	}
	cout<<sm<<endl;
}


Measured memory_bytes: 3612
#include <stdio.h>
int main(){
int x=0,y=0,soma=0;
scanf("%d %d",&x,&y);
if(x>y){
    soma=x+x-1;
    printf("%d",soma);
}
else if(x<y)
{
    soma=y+y-1;
    printf("%d",soma);
}
else
        printf("%d",x+y);
return 0;
}


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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}

#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pii pair<int,int>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i);
#define int unsigned long long int


signed main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n; cin >> n;
	int zero = 0;
	vector<int>vv;

	while (n--)
	{
		int a; cin >> a;
		if (a == 0)
		{
			cout << 0 << endll;
			return 0;
		}
		vv.emplace_back(a);
	}

	int ans = 1;
	for (int it : vv)
	{
		ans *= it;
		if (ans >= 1000000000000000000 or ans < 1)
		{
			if (ans != 1000000000000000000)
			{
				cout << -1 << endll;
				return 0;
			}
		}
	}
	cout << ans << endll;



}

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

public class Main {
	private static final int READ_COUNT = 1;
	private static List<String> strList = new ArrayList<>();
	
	public static void main(String[] args) {
		read();
		
		int n = Integer.parseInt(strList.get(0));
		
		if (n % 4 == 0 || n % 7 == 0) {
			System.out.println("Yes");
			return;
		}
		
		for (int i = 1, iLen = n / 7; i <= iLen; i++) {
			if ((n - (i * 7)) % 4 == 0) {
				System.out.println("Yes");
				return;
			}
		}
		
		System.out.println("No");
	}
	
	private static void read() {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			for (int i = 0; i < READ_COUNT; i++) {
				strList.add(br.readLine());
			}
		} catch (IOException e) {
		}
	}
}


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

int main(void){
  int K,A,B;
  cin >> K >> A >> B;
  for(int i=A;i<=B;i++){
    if(i%K==0){
      cout << "OK" << endl;
      break;
    } else if(i==B){
      cout << "NG" << endl;
    }
  }
  return 0;
    
 }

Measured memory_bytes: 3644
#include<iostream>

using namespace std;

int main()
{
    int a,b,k;
    cin >> a >> b >> k;

    for(int i = a;i <= b;i++){
        if(i <= a + k - 1){
            cout << i << endl;
        }
        else if(b - k + 1 <= i){
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

int N,K,A[111]={},ans=0;

int main() {
	cin>>N>>K;
	for(int i=0;i<K;i++){
		int d;
		cin>>d;
		for(int j=0;j<d;j++){
			int a;
			cin>>a;
			A[a]++;
		}
	}
	for(int i=1;i<=N;i++)if(A[i]==0)ans++;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>
using namespace std;
inline char gc(){
    static char now[1<<16],*S,*T;
    if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
    return *S++;
}
inline int read(){
    int x=0;char ch=gc();
    while(ch<'0'||ch>'9') ch=gc();
    while(ch<='9'&&ch>='0') x=x*10+ch-'0',ch=gc();
    return x;
}
int n,cnt[110000];
int main(){
  //  freopen("arc.in","r",stdin);
    n=read();int max1=0,x=0;for (int i=1;i<=n;++i) x=read(),max1=max(max1,x),cnt[x]++;int kind=0,sum=0;
    for (int i=1;i<=max1;++i) if (cnt[i]) sum+=cnt[i]-1,kind++;
    if (sum%2) kind--; printf("%d",kind);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n, w;

  	cin >> n >> w;
	vector<int> v(n+1), wei(n+1);
	
	for(int i=0;i<n;i++){
		cin>> v[i+1] >> wei[i+1];
	}
	int dp[n+1][w+1];
	
	for(int j=0;j<=w;j++){
		dp[0][j] = 0;
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<=w;j++){
			if(wei[i+1]<=j){
				dp[i+1][j] = max(dp[i][j-wei[i+1]]+v[i+1], max(dp[i][j], dp[i+1][j-wei[i+1]]+v[i+1]));
			}else{
				dp[i+1][j] = dp[i][j];
			}
		}
	}
	cout<<dp[n][w] <<endl;
}


Measured memory_bytes: 7052
//
//AtCoder Beginner Contest 076
//C
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

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

    int slen = s.size();
    int tlen = t.size();

    int maxIdx = -1;
    REP(i, slen-tlen+1){
        bool contains = true;
        REP(j, tlen){
            if (s[i+j] == t[j] || s[i+j]=='?') continue;
            contains = false;
            break;
        }
        if (contains) maxIdx=i;
    }

    if (maxIdx>=0) {
        REP(i,tlen) s[maxIdx+i] = t[i];
        REP(i,slen){
            if (s[i]=='?') s[i]='a';
        }
        cout << s << endl;
    }else{
        cout << "UNRESTORABLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
 
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
 
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int happiness[n][3] = {};
    for(int i=0;i<n;++i)
    {
        cin >> happiness[i][0] >> happiness[i][1] >> happiness[i][2];
    }
    int dp[n+1][3] = {};

    dp[0][0] = happiness[0][0];
    dp[0][1] = happiness[0][1];
    dp[0][2] = happiness[0][2];

    for(int i=1;i<n;++i)
    {
        for(int j=0;j<3;++j)
        {
            for(int k=0;k<3;++k)
            {
                if(j == k) continue;
                dp[i][k] = max(dp[i][k], dp[i-1][j] + happiness[i][k]);
            }
        }
    }
    int ret = 0;
    for(int i=0;i<3;++i)
    {
        ret = max(ret, dp[n-1][i]);
    }
    cout << ret << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#define range(s,n) for(int i = s; i < n; i++)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
	int n;
	long double x1,x2,x3,x4,y1,y2,y3,y4;

	while(cin >> n){
		range(0,n){
			cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
			if( (y2 - y1) / (x2 - x1) == (y4 - y3) / (x4 - x3) )
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1228
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int M = sc.nextInt();
        int D = sc.nextInt();
        int count = 0;
        for(int m = 4; m <= M; m++){
        for(int i = 2; i <= D/10; i++){
            for(int j = 2; j <= 9; j++){
                if(i == D/10 && j > D%10){
                    break;
                }
                if(i*j == m){
                    count++;
                }
            }
        }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 35860
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long N=sc.nextLong();
		int maxlen=12;
		long[] space=new long[maxlen];
		space[0]=1;
		int ketasu=0;
		String ans="";
		for(int i=1; i<maxlen; i++) {
			space[i]=space[i-1]*26;
		}
		for(int i=1; i<maxlen; i++) {
			space[i]+=space[i-1];
		}
		for(int i=1; i<maxlen; i++) {
			if(N>=space[i-1]) {
				ketasu=i;
			}
			else {
				break;
			}
		}
		N-=space[ketasu-1];
		//lp(N+" "+ketasu);
		for(int i=0; i<ketasu; i++) {
			ans=((char)(N%26+'a'))+ans;
			N/=26;
		}
		lp(ans);
	}
	public static void lp(Object o) {
		System.out.println(o);
	}
}

Measured memory_bytes: 39160
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int count = 0;
  bool b = true;
  for(int i = 0; i < N; i++) {
    int D, E;
    cin >> D >> E;
    if(D == E) {
      count++;
    }
    else {
      count = 0;
    }
    if(count == 3) {
      b = false;
      cout << "Yes" << endl;
      break;
    }
  }
  if(b) {
    cout << "No" << endl;
  }
}

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

int gcd(int a, int b){
	if(!b) return a;
	return gcd(b, a%b);
}

int main(){
	int x[2];
	int max_kyk, min_kbi, a,b;
	while(cin>>x[0]>>x[1]){		
		sort(x, x+2);
		max_kyk = gcd(x[1], x[0]);
		min_kbi = (x[1]/max_kyk)*x[0];
		cout << max_kyk << ' ' << min_kbi << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

const int range = 3e5+10;
bool used[range];
bool chosen[range];

int main(){
 int N; cin >> N;
  
  if( N < 6){
    
    if(N == 3){ cout << 2 << " " << 5 << " " << 63 << endl;}
    else if( N == 4){ cout << 2 << " " << 5 << " " << 20 << " " << 63 << endl;}
    else{ cout << 2 << " " << 5 << " " << 20 << " "<< 30 << " " << 63 << endl;}
    
    return 0;
    
  }
  else{
 
  
  priority_queue<int,vector<int>,greater<int>> Q;
  

  for(int i = 1; i <= range; i++){ 
    if(i%2 == 0){ Q.push(i); used[i] = true; }
    if(i%3 == 0 && !used[i]){ Q.push(i); used[i] = true;} 
  }
  
  ll test = 0;
    
    vector<bool> chosen(range,false);
    
    int last = 0;
    
    while(N--){
    ll p = Q.top(); Q.pop();
    test += p; chosen[p] = true; last = p;
    
    
  }
  
    
   
  if( test%6 == 2){
    
    chosen[8] = false; 
    
    for(int i = last+1; i <= range; i++){ 
      if(i%6 == 0){ chosen[i] = true; break;}
      
    }
  }
  else if( test%6 == 3){
    chosen[9] = false; 
    
    for(int i = last+1; i <= range; i++){ 
      if(i%6 == 0){ chosen[i] = true; break;}
      
    }
    
  }
  
  else if(test%6 == 5){ //test%6 == 5
    chosen[9] = false; 
    
    for(int i = last+1; i <= range; i++){ 
      if(i%6 == 4){ chosen[i] = true; break;}
      
    }
  }
  
  //出力
    
  for(int i = 0; i <= range; i++){ 
    if(chosen[i]){ cout << i << " ";}
  }
  
  cout << endl;
  
  }
  return 0;
}
  

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

int main(void){
    int a = 0, b = 0, c = 0, d = 0; 
    int ans = 0;

    scanf("%d%d%d%d", &a, &b, &c, &d);

    if(a <= b){
        ans = a;
    }else{
        ans = b;
    }

    if(c <= d){
        ans += c;
    }else{
        ans += d;
    }

    printf("%d\n", ans);

    return 0;

} 


Measured memory_bytes: 256
def solve():
    N = int(input())
    
    ans = 0
    for i in range(1, N+1, 2):
        c = 0
        for j in range(1, i+1):
            if i % j == 0:
                c += 1
        if c == 8:
            ans += 1

    return ans

print(solve())

Measured memory_bytes: 3316
N = map(int, input())
An = list(map(int, input().split()))
mnum = 10 ** 9 + 7
CumSum = An[0]
answer = 0
for i in range(1, len(An)):
    answer = (answer + CumSum * An[i]) 
    CumSum = (CumSum + An[i])
print(answer%mnum)

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int x4 = 0, x2 = 0;
    rep(i, n) {
        cin >> a[i];
        if (a[i]%4==0) {
            x4++;
        }
        if (a[i]%2==0) {
            x2++;
        }
    }
    int b1 = n-x2;
    int b2 = x2-x4;
    int b4 = x4;
    if (b4>=b1+(b2>0)*1-1) puts("Yes");
    else puts("No");
    return 0;
}

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



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

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}


double r;



int main()
{
    cin>>r;
    cout<<std::setprecision(10)<<2*r*M_PI<<endl;
    return 0;

}




Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;

    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }

    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

void solve(long long N, long long x, std::vector<long long> a)
{
    vector<ll> b(N);
    copy(a.begin(), a.end(), b.begin());
    ll cost1 = 0, cost2 = 0;
    // if (x < a[0])
    // {
    //     cost1 += a[0] - x;
    //     a[0] = x;
    // }
    for (int i = 0; i < N - 1; i++)
    {

        ll one = a[i];
        ll two = a[i + 1];

        if (one + two <= x)
        {
            continue;
        }
        else
        {
            if (one <= x)
            {
                cost1 += (one + two - x);
                a[i + 1] = x - one;
            }
            else
            {
                cost1 += (one + two - x);
                a[i + 1] = 0;
                a[i] = x;
            }
        }
    }
    cout << cost1 << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long x;
    scanf("%lld", &x);
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &a[i]);
    }
    solve(N, x, std::move(a));
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B; 
  cin >>A>>B;
  if(A>=13){
    cout<<B<<endl;
  }else if(A<=12&&A>=6){
    cout<<B/2<<endl;
  }else{
    cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	int t1,t2,t3,t4,n1,n2,n3,n4;
	cin>> t1>> n1>> t2>> n2>> t3>> n3>> t4>> n4;
	if(t1==1){
		cout<< n1*6000<<endl;
	}
	else if(t1==2){
		cout<< n1*4000<<endl;
	}
	else if(t1==3){
		cout<< n1*3000<<endl;
	}
	else if(t1==4){
		cout<< n1*2000<<endl;
	}
	if(t2==1){
		cout<< n2*6000<<endl;
	}
	else if(t2==2){
		cout<< n2*4000<<endl;
	}
	else if(t2==3){
		cout<< n2*3000<<endl;
	}
	else if(t2==4){
		cout<< n2*2000<<endl;
	}
	if(t3==1){
		cout<< n3*6000<<endl;
	}
	else if(t3==2){
		cout<< n3*4000<<endl;
	}
	else if(t3==3){
		cout<< n3*3000<<endl;
	}
	else if(t3==4){
		cout<< n3*2000<<endl;
	}
	if(t4==1){
		cout<< n4*6000<<endl;
	}
	else if(t4==2){
		cout<< n4*4000<<endl;
	}
	else if(t4==3){
		cout<< n4*3000<<endl;
	}
	else if(t4==4){
		cout<< n4*2000<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define sqr(x) (x*x)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

//#define int ll


const int N = 1e5+33, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const char pxy[] = {'R' , 'L' , 'D' , 'U'};
const double EPS = 1e-4;
const double PI = acos(-1.0);

template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;        // #include <ext/pb_ds/assoc_container.hpp>
typedef pair <ll, ll> pll;         // #include <ext/pb_ds/tree_policy.hpp>
typedef vector <int> vi;          // #include <ext/rope>
                // #include <ext/rope>
                                 // #include <ext/rope>
bool prime(int n) {             // template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){return 0;}
    }return 1;}
ll bp(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

void solve() {
    double r;
    cin >> r;
    cout << 2*PI*r;
}

/*
*/

main() {
    ios;
    int tt = 1;
//    cin >> tt;
    while(tt --) {
        solve();
        cout << '\n';
    }
    return 0;
}
/*
++>
+++>
<[<+>-]<
++++++++++++++++++++++++++++++++++++++++++++++++.

500000000000000000000000000000000000000000000000

1 1 2 3 6


*/


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

int main()
{
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a==0)
		cout<<1;
	else if(b==0)
		cout<<2;
	else if(c==0)
		cout<<3;
	else if(d==0)
		cout<<4;
	else
		cout<<5;

	return 0;
}

Measured memory_bytes: 3632
//32
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

int main(){
  bool ns=false;
  for(int n;cin>>n;){
    const char* s="SCHD";
    int b[128][13];
    for(int i=0;i<4;i++){
      for(int j=0;j<13;j++){
	cin>>b[s[i]][j];
      }
    }
    int m[10]={};
    for(int i=0;i<9;i++){
      cin>>m[i+1];
    }
    if(ns){
      cout<<endl;
    }
    ns=true;
    while(n--){
      const char *r="A23456789TJQK";
      int apr[13]={},aps[128]={};
      char rn[5],st[5];
      int rnd[5];
      for(int i=0;i<5;i++){
	cin>>rn[i]>>st[i];
	rnd[i]=strchr(r,rn[i])-r;
	apr[rnd[i]]++;
	aps[st[i]]++;
      }
      int p;
      p=count(apr,apr+13,2);
      int tf=*max_element(apr,apr+13);
      if(tf==3){
	p=3;
      }
      bool str=false;
      int sp;
      for(int i=0;i<13-3;i++){
	int h=true;
	for(int j=0;j<5;j++){
	  h&=apr[(i+j)%13];
	}
	if(h){
	  str=true;
	  p=4;
	  sp=i;
	}
      }
      bool fl=find(aps,aps+128,5)!=aps+128;
      if(fl){
	p=5;
      }
      if(find(apr,apr+13,2)!=apr+13&&find(apr,apr+13,3)!=apr+13){
	p=6;
      }
      if(tf==4){
	p=7;
      }
      if(str&&fl){
	p=8+(sp==9);
      }
      int bp=0;
      for(int i=0;i<5;i++){
	bp+=b[st[i]][rnd[i]];
      }
      cout<<bp*m[p]<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <climits>
using namespace std;
typedef long long ll;

const int INFTY=INT_MAX;
const int maxn=500000;

int L[maxn/2+2],R[maxn/2+2];

ll merge(int *Array,int left,int mid,int right) {
  int n1=mid-left;
  int n2=right-mid;
  ll count=0;
  for (int i=0; i<n1; i++) {
    L[i]=Array[left+i];
  }
  for (int i=0; i<n2; i++) {
    R[i]=Array[mid+i];
  }
  L[n1]=R[n2]=INFTY;
  int i=0,j=0;
  for (int k=left; k<right; k++) {
    if (L[i]<=R[j]) {
      Array[k]=L[i++];
    }
    else {
      Array[k]=R[j++];
      count+=n1-i;
    }
  }
  return count;
}
ll mergeSort(int *Array,int left,int right) {
  ll v1,v2,v3;
  if (left+1<right) {
    int mid=(left+right)/2;
    v1=mergeSort(Array,left,mid);
    v2=mergeSort(Array,mid,right);
    v3=merge(Array,left,mid,right);
    return v1+v2+v3;
  }
  else {
    return 0;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  int n;
  cin>>n;
  int S[n];
  for (int i=0; i<n; i++) {
    cin>>S[i];
  }
  ll ans=mergeSort(S,0,n);
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 4736
#include<iostream>
using namespace std;
int main()
{
	int k,i,j,n,p[1000],m;
	cin>>k>>n;
	for(i=0;i<k;i++)
	{
		cin>>p[i];
	}
	for(i=0;i<k-1;i++)
	{
		for(j=i+1;j<k;j++)
		{
		    if(p[j]<p[i])
		    {
		    	m=p[j];
		    	p[j]=p[i];
		    	p[i]=m;
			}
		 }
	}
	m=0;
	for(i=0;i<n;i++)
	{
		m+=p[i];
	}
	cout<<m;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
int main(){
	int n;
	scanf("%d",&n);
	int a[n]={};
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	std::sort(a,a+n);
	printf("%d\n",a[n-1]-a[0]);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

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

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

    int cnt2 = 0;
    int cnt4 = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] % 4 == 0) {
            ++cnt4;
        } else if (a[i] % 2 == 0) {
            ++cnt2;
        }
    }

    if (cnt2 != 0) {
        N = N - cnt2 + 1;
    }

    if (N - 2 * cnt4 <= 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    cout << (700 + 100 * count(s.begin(), s.end(), 'o')) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<queue>
using namespace std;
typedef pair<int,int> i_i;
int o,h,w,c;
void rec(int st[8][8],int d){
  if(d==5){
    queue<i_i> q;
    vector<i_i> v;
    int u[8][8]={{}};
    i_i p,b;
    p.first=0;p.second=0;
    if(st[p.first][p.second]==c) q.push(p);
    u[p.first][p.second]=1;
    int ax[]={1,-1,0,0},ay[]={0,0,1,-1};
    while(!q.empty()){
      p=q.front();q.pop();
      v.push_back(p);
      for(int i=0;i<4;i++){
	b.first=p.first+ax[i];
	b.second=p.second+ay[i];
	if(b.first<0||b.first>=w||
	   b.second<0||b.second>=h) continue;
	if(u[b.first][b.second]==0&&
	   st[b.first][b.second]==c){
	  u[b.first][b.second]=1;
	  q.push(b);
	}
      }
    }
    int s=v.size();
    o=max(o,s);
    return;
  }
  
  queue<i_i> q;
  vector<i_i> v;
  int u[8][8]={{}};
  i_i p,b;
  p.first=0;p.second=0;
  int bc=st[p.first][p.second];
  u[p.first][p.second]=1;
  q.push(p);
  int ax[]={1,-1,0,0},ay[]={0,0,1,-1};
  while(!q.empty()){
    p=q.front();q.pop();
    v.push_back(p);
    for(int i=0;i<4;i++){
      b.first=p.first+ax[i];
      b.second=p.second+ay[i];
      if(b.first<0||b.first>=w||
	 b.second<0||b.second>=h) continue;
      if(u[b.first][b.second]==0&&
	 st[b.first][b.second]==bc){
	u[b.first][b.second]=1;
	q.push(b);
      }
    }
  }
  /*
  cout << d << ":";
  for(int j=0;j<v.size();j++){
    cout << v[j].first << ":" << v[j].second << endl;
  }
  
  
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout << st[j][i] << " ";
    }
    cout <<  endl;
  }
  cout << d << ":" << v.size() << endl;
  
  */
  int stage[8][8]={{}};
  for(int i=1;i<=6;i++){
    for(int j=0;j<h;j++)
      for(int k=0;k<w;k++)
	stage[k][j]=st[k][j];
    for(int j=0;j<v.size();j++){
      stage[v[j].first][v[j].second]=i;
    }
    rec(stage,d+1);
  }
  
}
int main(){
  cin >> h >> w >> c;
  while(h!=0){
    o=0;
    int st[8][8]={{}};
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> st[j][i];
      }
    }
    rec(st,0);
    cout << o << endl;
    cin >> h >> w >> c;
  }
  return 0;
}

Measured memory_bytes: 1212
n = int(input())

word_set = set()

chaine = []
for i in range(n):
  w = input()
  word_set.add(w)
  if chaine == []: 
    chaine.append( w[0] + w[-1] )
  else:
    if chaine[-1][-1] == w[0]:
      chaine.append( w[0] + w[-1] )

if len(word_set) == n and len(chaine) == n:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
# 2019/05/24
# AtCoder Beginner Contest 066 - C

# For the answer:
# Odd:(n==9)
# 753102468
# Even:(n==8)
# 75310246

# Input
n = int(input())
a = list(input().split())
ansl = list()

# Calc Start Index
if n % 2 == 1:
    sidx = n - 2
else:
    sidx = n - 1

# Append Left
for i in range(sidx, -1, -2):
    ansl.append(a[i])

# Append Right
for i in range(0, n, 2):
    ansl.append(a[i])

# Case odd: Reverse list
if n % 2 == 1:
    ansl.reverse()

# Make Output String
ans = ""
for i in range(n):
    ans += ansl[i] + " "

# Output
print(ans)


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double eps = -1e10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second


int nextit[30], dp[200010];
string s;
vector<pair<char, int>>ans;

int main() {
	cin >> s;
	fill(dp, dp + (int)s.size() + 2, 1000000);
	fill(nextit, nextit + 26, s.size() + 1);
	dp[s.size()] = 1;
	dp[s.size() + 1] = 0;
	ans.resize((int)s.size() + 2);
	ans[(int)s.size()] = make_pair('a', s.size() + 1);
	for (int i = s.size();i >= 0;i--) {
		for (int j = 0;j < 26;j++) {
			if (dp[nextit[j]] + 1 >= dp[i])continue;
			ans[i] = make_pair('a' + j, nextit[j]);
			dp[i] = dp[nextit[j]] + 1;
		}
		if (i)nextit[s[i - 1] - 'a'] = i;
	}
	string an;
	for (int i = 0;i < s.size() + 1;) {
		an += ans[i].fr;
		i = ans[i].sc;
	}
	cout << an << endl;
	return 0;
}


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

using namespace std;

int main() {

	int n;
	cin >> n  ;

	vector<int> hk(n+1, 0);
	for (int i = 0; i < n; i++) {
		cin >> hk[i];
	}

	vector<int> h(n+1, 0);
	int counter = 0;
	while (1) {
		int r=0, l=0;
		for (int i = 0; i < n; i++) {
			r = 0;
			l= 0;
			if(h[i]!=hk[i] && l==0){
				l = i;
				int j = 0;
				for (j = i; j < n; j++) {
					if ((h[j] != hk[j] && h[j + 1] == hk[j + 1])
						|| j+1==n) {
						r = j;

						for (int k = l; k <= r; k++) {
							h[k]++;
						}
						counter++;
						break;
					}
				}
				i = j;
			}

		}

		bool contflg = false;
		for (int i = 0; i < n; i++) {
			if (hk[i] != h[i]) { contflg = true; }
		}
		if (contflg == false) { cout << counter << endl; return 0; }

	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static String line;
	public static void main(String[] args){
		while(read()){

		}
	}
	static boolean read(){
		if(!sc.hasNext())return false;

		int n = sc.nextInt();
		for(int i = 0; i < n; i++){
			line = sc.next();
			solve();
		}
		return true;
	}
	static void solve(){
		char[] number = new char[8];
		number = line.toCharArray();
		java.util.Arrays.sort(number);
		int minValue = Integer.parseInt(new String(number));
		char[] m = new char[8];
		for(int i = 0; i < number.length; i++){
			m[i] = number[7 - i];
		}
		int maxValue = Integer.parseInt(new String(m));
		System.out.println(maxValue - minValue);
	}
}

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

using namespace std;

int main()
{
    int n,k,c;
    string s;
    cin>>n>>k>>c;
    cin>>s;
    vector<int>pos(k+1);
    pos[k]=200005;
    int crpos=-200005;
    int crk=0;
    for(int i=0;i<n;i++){
        if(s[i]=='o'){
            if(crk<k&&i-crpos>c){
                pos[crk]=i;
                crpos=i;
                crk++;
            }
        }
    }
    vector<int>ans;
    int crvld=n-1;
    for(int i=k-1;i>=0;i--){
        while(s[crvld]=='x'||pos[i+1]-crvld<=c) crvld--;
        if(crvld==pos[i]){
            ans.push_back(pos[i]+1);
        }else{
            pos[i]=crvld;
        }
    }
    for(int i=ans.size()-1;i>=0;i--)
        cout << ans[i] << '\n';
    return 0;
}
/***
11 3 2
ooxxxoxxxoo
*/


Measured memory_bytes: 5176
#!usr/bin/env python3

import sys


class Die:
    def __init__(self, pips):
        self.pips = pips

    def move_die(self, direction):
        if direction == 'N':
            tmp = self.pips[0]
            self.pips[0] = self.pips[1]
            self.pips[1] = self.pips[5]
            self.pips[5] = self.pips[4]
            self.pips[4] = tmp
            del tmp
        elif direction == 'S':
            tmp = self.pips[0]
            self.pips[0] = self.pips[4]
            self.pips[4] = self.pips[5]
            self.pips[5] = self.pips[1]
            self.pips[1] = tmp
            del tmp
        elif direction == 'E':
            tmp = self.pips[0]
            self.pips[0] = self.pips[3]
            self.pips[3] = self.pips[5]
            self.pips[5] = self.pips[2]
            self.pips[2] = tmp
            del tmp
        elif direction == 'W':
            tmp = self.pips[0]
            self.pips[0] = self.pips[2]
            self.pips[2] = self.pips[5]
            self.pips[5] = self.pips[3]
            self.pips[3] = tmp
            del tmp

    def spin_die_clockwise(self):
        tmp = self.pips[1]
        self.pips[1] = self.pips[2]
        self.pips[2] = self.pips[4]
        self.pips[4] = self.pips[3]
        self.pips[3] = tmp
        del tmp

    def get_upside(self):
        return self.pips[0]

    def get_frontside(self):
        return self.pips[1]

    def get_rightside(self):
        return self.pips[2]


def init_die():
    pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]
    die = Die(pips)

    return die


def roll_die(die):
    directions = list(sys.stdin.readline().strip('\n'))

    for direction in directions:
        die.move_die(direction)

    return die


def main():
    die = init_die()
    q = int(sys.stdin.readline().strip('\n'))

    for question in range(q):
        q_pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]

        if q_pips[0] == die.pips[1]:
            die.move_die('N')
        elif q_pips[0] == die.pips[2]:
            die.move_die('W')
        elif q_pips[0] == die.pips[3]:
            die.move_die('E')
        elif q_pips[0] == die.pips[4]:
            die.move_die('S')
        elif q_pips[0] == die.pips[5]:
            die.move_die('N')
            die.move_die('N')

        while die.get_frontside() != q_pips[1]:
            die.spin_die_clockwise()

        print(die.get_rightside())


if __name__ == '__main__':
    main()

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

N = int(input())
A = list(map(int, input().split()))

pm = min(A)
m = pm
while True:
    na = [a % m for a in A if a % m != 0]
    if len(na) == 0:
        break
    pm, m = m, min(na)
    if pm == m:
        break

print(m)

Measured memory_bytes: 14224