akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    a = LI()
    ans = 0
    for i in a:
        ans ^= i
    if not ans:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = I()

    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    A()


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

int	main()
{
  string	s;
  int		begin, end, i = 0;
  
  cin >> s;
  for (; i < s.size(); i++)
  {
    if (s.at(i) == 'A')
    {
      begin = i;
      break;
    }
  }
  for(; i < s.size(); i++)
  {
    if (s.at(i) == 'Z')
      end = i;
  }
  cout << end - begin + 1 << endl;
  return (0);
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repp(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
using namespace std;
vector<int> adj[100003];
int vis[100003]={0};
int dp[100003]={0};
int solve(int n)
{
    vis[n]=1;
    rep(i,0,adj[n].size())
    {
        if(!vis[adj[n][i]])
        solve(adj[n][i]);
        dp[n]=max(dp[n],1+dp[adj[n][i]]);
    }
}
signed main()
{
    int n,m;
    cin>>n>>m;
    repp(i,1,m)
    {
        int a,b; cin>>a>>b;
        adj[a].pb(b);
    }
    repp(i,1,n)
    {
        if(!vis[i])solve(i);
    }
    int ans=0;
    repp(i,1,n)
    {
        ans=max(ans,dp[i]);
    }
    cout<<ans;
}

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

typedef unsigned uint;
typedef long long INT;
typedef unsigned long long UINT;
const int INF = 1001001001;
const INT INFLL = 1001001001001001001LL;

 int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
INT lin() { INT x; scanf("%lld", &x); return x; }

int main(){
    int a, b, c;
    double fa, fb, fc;
    char S[128], sa[128], sb[128], sc[128];
    // int N = in();
    // int K = in();
    // scanf("%s", S);

    int R = in();
    printf("%lf", 2 * R * 3.1415926535);



    return 0;
}







Measured memory_bytes: 3824
import java.util.Scanner;
  
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        if (S.compareTo("2019/04/30") > 0) {
            System.out.println("TBD");
        }
        else {
            System.out.println("Heisei");
        }
    }
}


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

int main(){
	long long s,c;	cin>>s>>c;

	long long ans=0;
	if(c<=s*2){
		// "S"が余る
		ans=c/2;
	}else{
		// "cc"が余る
		ans=s;
		c-=(ans*2);

		ans+=c/4;
	}

	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        int r = obj.nextInt();
        System.out.print(2*Math.PI*r);
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
    char c;
    cin >> c;
    if(c >= 'a' && c <= 'z'){
        cout << 'a' << endl;
    }else{
        cout << 'A' << endl;
    }

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int N,M,X; cin >> N >> M >> X;
	int a[1000]; memset(a,0,sizeof(a));
	for (int i = 0;i < M;i++){
		int tmp; cin >> tmp;
		a[tmp]++;
	}

	int ans;
	int cost = 0;
	for (int i = X-1;i >= 0;i--){
		cost += a[i];
	}
	ans = cost; cost = 0;

	for (int i = X+1;i <= N;i++){
		cost += a[i];
	}

	cout << min(ans,cost) << endl;

	return 0;

}


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



int main()
{
	

	int L, R;
	int j = 0;
	vector<int> v;
	
	cin >> L >> R;

	if (R-L+1>=2019)
	{
		
		cout << 0 << endl;
	}
	else {
		for (int i = L; i < R; i++)
		{
			for (int k = i+1; k <= R; k++)
			{
				v.push_back(((i % 2019) * (k % 2019)) % 2019);
				
			}
			
		

		}
		sort(v.begin(), v.end());
		cout << v[0] << endl;
	}
}

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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const i64 maxn = 2*(int)1e5+1000;
const i64 mod = 998244353;

i64 fac[maxn],inv[maxn];
i64 pow_mod(i64 a,i64 n)
{
    i64 ret =1;
    while(n)
    {
        if(n&1) ret=ret*a%mod;
          a=a*a%mod;
          n>>=1;
    }
    return ret;
}
void init()
{
    fac[0]=1;
    for(i64 i=1;i<maxn;i++)
    {
        fac[i]=fac[i-1]*i%mod;
    }
}
i64 CC(i64 x, i64 y)
{
    return fac[x]*pow_mod(fac[y]*fac[x-y]%mod,mod-2)%mod;
}
i64 n, m, k;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    init();
    cin >> n >> m >> k;
    i64 ans = 0;
    for (int i = 0; i <= k; ++i) {
        ans += CC(n-1,i)*m%mod*pow_mod(m-1,n-1-i)%mod;
        ans %= mod;
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

int main(){
    int n,m,maxl = 0,minr = 1e5+1;
    cin >> n >> m;
    for(int i = 0;i < m;i ++){
        int l,r;
        cin >> l >> r;
        maxl = max(l,maxl);
        minr = min(r,minr);
    }
    cout << max(minr - maxl + 1,0) << endl;
    return 0;
}

Measured memory_bytes: 256
s=str(input())
n=len(s)
ans=1
if n%2==1:
    ans=0

for i in range(n):
    if i%2==0 and s[i]!='h':
        ans=0
    if i%2==1 and s[i]!='i':
        ans=0
if ans==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int X, Y, A, B, C;
  vector<ll> p,q,r;

  cin >> X >> Y >> A >> B >> C;
  rep(i,A){
    ll a;
    cin >> a;
    p.push_back(a);
  }
  rep(i,B){
    ll a;
    cin >> a;
    q.push_back(a);
  }
  rep(i,C){
    ll a;
    cin >> a;
    r.push_back(a);
  }

  sort(ALLOF(p));
  reverse(ALLOF(p));
  sort(ALLOF(q));
  reverse(ALLOF(q));
  sort(ALLOF(r));
  reverse(ALLOF(r));

  ll sum = 0;
  priority_queue<ll,vector<ll>, greater<ll>> que;
  rep(i,X){
    que.push(p[i]);
    sum += p[i];
  }
  rep(i,Y){
    que.push(q[i]);
    sum += q[i];
  }

  ll ret = sum;
  rep(i,r.size()){
    ll x = que.top(); que.pop();
    ll y = r[i];
    if(x < y){
      sum -= x;
      sum += y;
      ret = max(ret, sum);
      que.push(y);
    }else{
      que.push(x);
    }
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 4724
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll a;
    long double b;
    cin >> a >> b;
    long double c = a * b;
    ll ans = floorl(c);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3784
n, m = map(int, input().split())

from collections import defaultdict
d = defaultdict(list)
for _ in range(m):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)
    
if len(set(d[1]) & set(d[n])) >= 1:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 60120
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
const int N=200000;
int n;
int a[N+1];
int buc[N+1];
 
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],buc[a[i]]++;
	int ans=0;
	for(int i=1;i<=n;i++)ans+=buc[i]*(buc[i]-1)/2; 
	for(int i=1;i<=n;i++)cout<<ans-(buc[a[i]]-1)<<"\n";
	return 0;
}

Measured memory_bytes: 4736
n = int(input())
li_a = list(map(int,input().split()))
li_b = list(map(int,input().split()))
li_c = list(map(int,input().split()))
ans = 0
for i in range(n):
  if i==0:
    ans += li_b[li_a[0]-1]
    continue
  else:
    ans += li_b[li_a[i]-1]
    if li_a[i-1] + 1 == li_a[i]:
      ans += li_c[li_a[i-1]-1]
print(ans)

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

ABC = LIST()
for x in ABC:
	if ABC.count(x) == 1:
		print(x)


Measured memory_bytes: 5332
//atcoder.jp abc 120 d
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;

inline ll read() {
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=1e5+5;
int n,m,fa[MAXN];

struct EDGE {
	int u,v;
}e[MAXN];

ll ans[MAXN],sz[MAXN];

int get_fa(int x) {
	if(x==fa[x]) return x;
	return fa[x]=get_fa(fa[x]);
}

int main() {
    //freopen("","r",stdin);
    //freopen("","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);/*syn加速*/
	n=read();m=read();
	
	for(int i=1;i<=m;++i) {
		e[i].u=read(); e[i].v=read();
	}
	
	for(int i=1;i<=n;++i) 
	   fa[i]=i,sz[i]=1;
	
	ans[m]=(ll)n*(n-1)/2;
	
	for(int i=m;i>=1;--i) {
		int u=get_fa(e[i].u),v=get_fa(e[i].v);
		if(u==v) 
		    ans[i-1]=ans[i];
		else {
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u]; fa[u]=v;
		}
	}
	
	for(int i=1;i<=m;++i) 
	   cout<<ans[i]<<endl;
	return 0;
} 

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

using namespace std;

#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

string s;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>s;
    s[3]='8';
    cout<<s<<endl;
}

Measured memory_bytes: 256
n,q = map(int,input().split())
s = input()
t = [0]*(n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] == 'AC' else 0)
for i in range(q):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])

Measured memory_bytes: 9284
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication1
{
	class Q2
	{
		static void Main()
		{
			string[] buff = Console.ReadLine().Split(' ');
			int H = int.Parse(buff[0]);
			List<string> strs = Enumerable.Range(1, H).Select(x => Console.ReadLine()).ToList();
			foreach(string str in strs)
			{
				Console.WriteLine(str);
				Console.WriteLine(str);
			}
		}
	}
}


Measured memory_bytes: 2904
fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    var s = sc.next()
    var t = sc.next()
    var a = sc.nextInt()
    var b = sc.nextInt()

    var u = sc.next()

    print(a - if (s == u) 1 else 0)
    print(" ")
    print(b - if (t == u) 1 else 0)
}


Measured memory_bytes: 31268
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>


using namespace std;

int main(){
    int n;
    cin >> n;
    vector<double> vec(n,0);
    for (int i=0;i<n;i++) cin >> vec[i] ;
    sort(vec.begin(),vec.end());
    double ans=vec[0];
    for (int i=1;i<n;i++){
        ans+=vec[i];
        ans/=2;
    }
    printf("%.12f\n",ans);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
char Str[5];

int main(){
    int i;
    scanf( "%s" , Str );

    for( i = 0 ; i < 3 ; ++i ){
        if( Str[i] == Str[i + 1] ){ 
            puts( "Bad" );
            return 0;
        }
    }

    puts( "Good" );
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
typedef long long ll;
const int MAX=1e5+10;
int main()
{
	string S[105];
	int i=1;
	while(cin>>S[i++]);
	cout<<"A";
	cout<<S[2][0];
	for(int j=3;j<=i-1;j++)
	if(S[i][0]>='A'&&S[i][0]<='Z')cout<<S[i][0]-'A'+'a';
	cout<<"C";
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
s = list(input())

num_r = s.count('R')
num_g = s.count('G')
num_b = s.count('B')

ans = num_r*num_g*num_b

for i in range(n):
    for j in range(i, n):
        k = j+(j-i)
        if (k < n) and (s[i] != s[j]) and (s[j] != s[k]) and (s[k] != s[i]):
            ans -= 1
print(ans)


Measured memory_bytes: 9180
from random import randint
import sys
input = sys.stdin.readline
INF = 9223372036854775808


def calc_score(D, C, S, T):
    """
    開催日程Tを受け取ってそこまでのスコアを返す
    コンテストi 0-indexed
    d 0-indexed
    """
    score = 0
    last = [0]*26  # コンテストiを前回開催した日
    for d, t in enumerate(T):
        last[t] = d + 1
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
        score += S[d][t]
    return score


def update_score(D, C, S, T, score, ct, ci):
    """
    ct日目のコンテストをコンテストciに変更する
    スコアを差分更新する

    ct: change t 変更日 0-indexed
    ci: change i 変更コンテスト 0-indexed
    """
    new_score = score
    last = [0]*26  # コンテストiを前回開催した日
    prei = T[ct]  # 変更前に開催する予定だったコンテストi
    for d, t in enumerate(T, start=1):
        last[t] = d
        new_score += (d - last[prei])*C[prei]
        new_score += (d - last[ci])*C[ci]
    last = [0]*26
    for d, t in enumerate(T, start=1):
        if d-1 == ct:
            last[ci] = d
        else:
            last[t] = d
        new_score -= (d - last[prei])*C[prei]
        new_score -= (d - last[ci])*C[ci]
    new_score -= S[ct][prei]
    new_score += S[ct][ci]
    return new_score


def local_search():
    pass


def main(D, C, S):
    T = []
    for d in range(D):
        # d日目終了時点で満足度が一番高くなるようなコンテストiを開催する
        max_score = -INF
        best_i = 1
        for i in range(26):
            T.append(i)
            score = calc_score(D, C, S, T)
            if max_score < score:
                max_score = score
                best_i = i
            T.pop()
        T.append(best_i)
    return T


if __name__ == '__main__':
    D = int(input())
    C = [int(i) for i in input().split()]
    S = [[int(i) for i in input().split()] for j in range(D)]
    T = [int(input())-1 for i in range(D)]
    M = int(input())
    DQ = [[int(i)-1 for i in input().split()] for j in range(M)]
    score = calc_score(D, C, S, T)
    for d, q in DQ:
        score = update_score(D, C, S, T, score, d, q)
        T[d] = q
        print(score)


Measured memory_bytes: 97780
from sys import stdin
import numpy as np
import sys
import math
n,d = [int(x) for x in stdin.readline().rstrip().split()]
data = [stdin.readline().rstrip().split() for _ in range(n)]

ans = 0
wk = 0
for i in range(n):
  wk = math.sqrt(int(data[i][0])**2 + int(data[i][1])**2)
  if wk <= d:
    ans = ans + 1

    
print(ans)

Measured memory_bytes: 85648
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    ABulletinBoard solver = new ABulletinBoard();
    solver.solve(1, in, out);
    out.close();
  }

  static class ABulletinBoard {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int h = in.nextInt();
      int w = in.nextInt();
      int count = 0;
      int[][] arr = new int[n][n];
      for (int i = 0; i <= n - h; i++) {
        for (int j = 0; j <= n - w; j++) {
          count++;
        }
      }
      out.println(count);
    }

  }

  static class InputReader implements AutoCloseable {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      //reader = new BufferedReader(new FileReader(stream), 32768);
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

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

    public void close() {
    }

  }
}



Measured memory_bytes: 22740
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if X == 500*i + 100*j + 50*k:
                cnt+=1

print(cnt) 


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


using namespace std;

const int maxi=1e6+5;

int n,k;
int a[maxi];
int mm,nzd;
int main()
{
   cin>>n>>k;

   for (int i=1;i<=n;i++)
   {
       scanf("%d",&a[i]);
       mm=max(mm,a[i]);
       if (i==1) nzd=a[1]; else nzd=__gcd(nzd,a[i]);
   }

  if (mm>=k && (mm-k)%nzd==0) printf("POSSIBLE\n"); else printf("IMPOSSIBLE\n");
   return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A, B;

	cin >> A >> B;
	int ans = A + B;
	if (ans >= 10) {
		cout << "error" << "\n";
		return 0;
	}

	cout << ans << "\n";

	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 int i,j,c,n;
 c=0;
 cin >> n;
 int a[n];
 map<int,int> m;
 set<int> s;
 for(i=0;i<n;i++)
 {
  cin >> a[i];
  m[a[i]]++;
  s.insert(a[i]);
 }
 for(i=0;i<n;i++)
 {
  if(m[a[i]]==1)
  {
   set<int> x;
   for(j=1;j<=sqrt(a[i]);j++)
   {
    if(a[i]%j==0)
    {
     x.insert(j);
     x.insert(a[i]/j);
    }
   }
   int f=1;
   x.erase(a[i]);
   for(auto it:x)
   {
    if(s.find(it)!=s.end())
    {
     f=0;
     break;
    }
   }
   c+=f;
  }
 }
 cout << c;
 return 0;
}

Measured memory_bytes: 23220
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<bitset>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n, s;
    cin >> n;
    vector<int> a(n);
    rep(n) cin >> a[i];
    s = accumulate(all(a), 0);
    bitset<4000001> bs(0LL);

    bs.set(0);
    rep(n){
        bitset<4000001> bs2(bs);
        bs2 <<= a[i];
        bs |= bs2;
    }
    reppp(i, (s+1)/2, s+1){
        if(bs[i]){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


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

int main()
{
    long long n,k,d,a,b;

    cin>>n>>k>>d;

    a=abs(n);
    b=a/d;
    if(a%d==1){
        b++;
    }
    a=abs(a-d*min(b,k));

    k=k-min(b,k);
    if(k>0){
        if(k%2==1){
            a=abs(a-d);
        }
    }
    cout<<a;

    return 0;
}


Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		if (A == B){
			System.out.println(C);
		} else if (A == C) {
			System.out.println(B);
		} else {
			System.out.println(A);
		}
	}
}


Measured memory_bytes: 23764
A,B,C = map(int, input().split())
    
if (A+B+C) % 2 == (3*max(A,B,C)) % 2:
    print((3*max(A,B,C) - (A+B+C)) // 2)
else:
    print((3*(max(A,B,C)+1) - (A+B+C)) // 2)

Measured memory_bytes: 3060
/*
Dice I
ITP1_11_A
ダイス
上面に持ってくる
*/

package main

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

func rotate(dice []string, direction string) []string {
	var top string
	dm := map[string][4]int{
		"N": {1, 5, 6, 2},
		"E": {1, 3, 6, 4},
		"W": {1, 4, 6, 3},
		"S": {1, 2, 6, 5},
	}

	top = dice[dm[direction][3]-1] /* 上面に持ってくる面の数値 */
	for i := 3; i >= 1; i-- {
		// fmt.Println(dice)
		// fmt.Printf("direction:%s i:%d idx:%d ", direction, i, dm[direction][i])
		idx := dm[direction][i] - 1
		idxm := dm[direction][i-1] - 1
		// fmt.Printf("idx:%d idxm:%d\n", idx, idxm)
		dice[idx] = dice[idxm]
		// dice[dm[direction][i]] = dice[dm[direction][i-1]]
	}
	dice[dm[direction][0]-1] = top

	return dice
}

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	dice := strings.Split(stdin.Text(), " ")

	stdin.Scan()
	cmd := strings.Split(stdin.Text(), "")

	// fmt.Println(eyes)
	// fmt.Println(cmd)

	for i := 0; i < len(cmd); i++ {
		dice = rotate(dice, cmd[i])
	}

	// fmt.Println(cmd)

	fmt.Println(dice[0])
}


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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vp;

ll peso[110], costo[110];

ll dp[110][101000];

int main(){
	int n, w;
	sii(n, w);
	for(int i = 1; i <= n; i++){
		sl(peso[i]);
		sl(costo[i]);
	}

	memset(dp, -1, sizeof(dp));
	dp[0][0] = 0;
	ll vvv = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= 100000; j++){
			ll ans = -1;
			if(dp[i-1][j] != -1)
				ans = dp[i-1][j];
			if(j-costo[i] >= 0 && dp[i-1][j - costo[i]] != -1){
				if(ans != -1)
					ans = min(ans, dp[i-1][j - costo[i]] + peso[i]);
				else
					ans = dp[i-1][j - costo[i]] + peso[i];
			}
			dp[i][j] = ans;
			if(ans != -1 && dp[i][j] <= w)
				vvv = max((ll)j, vvv);
		}
	}
	printf("%lld\n", vvv);
    return 0;
}

Measured memory_bytes: 90456
#include <stdio.h>

int main(){
	long long int n;
	long long int sum = 0;
	scanf("%lld" ,&n);
	for(int i = 1; i <= n; i++){
	if(i % 3 == 0 && i % 5 == 0){
		continue;
	}
	else if(i % 3 == 0){
		continue;
	}
	else if(i % 5 == 0){
		continue;
	}
	else{
		sum = sum + i;
	}
		}
	printf("%lld\n" ,sum);
	return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, K;
bool snuke[110];
signed main() {
    cin >> N >> K;
    rep(i, K) {
        int d;
        cin >> d;
        rep(j, d) {
            int A;
            cin >> A;
            A--;
            snuke[A] = true;
        }
    }
    int ans = 0;
    rep(i, N) { if (!snuke[i]) { ans++; }}
    cout << ans << endl;
}


Measured memory_bytes: 3632
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			int r = sc.nextInt();
			int s = sc.nextInt();
			int p = sc.nextInt();
			String t = sc.next();
			char[] tArray = t.toCharArray();
			Set<Integer> skipped = new HashSet<Integer>();

			long result = 0;
			for (int i = 0; i < n; i++) {
				if (i < k) {
					result += getPoint(r, s, p, tArray[i]);
				} else {
					if (tArray[i] != tArray[i - k]) {
						result += getPoint(r, s, p, tArray[i]);
					} else {
						if (skipped.contains(i - k)) {
							result += getPoint(r, s, p, tArray[i]);
						} else {
							skipped.add(i);
						}
					}
				}
			}

			System.out.println(result);
		}
	}

	private static int getPoint(int r, int s, int p, char enemy) {
		if (enemy == 'r') {
			return p;
		} else if (enemy == 's') {
			return r;
		} else {
			return s;
		}
	}
}


Measured memory_bytes: 30640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <ctime>
//#define ivorysi
#define MAXN 2005
#define eps 1e-7
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
int N,a[MAXN * 2];
char c[MAXN * 2][5];
int tr[2][MAXN],cost[2][MAXN][MAXN],dp[MAXN][MAXN];
int lowbit(int x) {return x & (-x);}
void Insert(int id,int x) {
    while(x <= N) {
        tr[id][x]++;
        x += lowbit(x);
    }
}
int Query(int id,int x) {
    int res = 0;
    while(x > 0) {
        res += tr[id][x];
        x -= lowbit(x);
    }
    return res;
}
void Solve() {
    scanf("%d",&N);
    for(int i = 1 ; i <= 2 * N ; ++i) {
        scanf("%s%d",c[i] + 1,&a[i]);
    }
    for(int i = 1 ; i <= 2 * N ; ++i) {
        if(c[i][1] == 'W') {
            for(int j = 0 ; j <= N ; ++j) {
            cost[0][a[i] - 1][j] = (i - 1) - Query(0,a[i] - 1) - Query(1,j);
            }
            Insert(0,a[i]);
        }
        else {
            for(int j = 0 ; j <= N ; ++j) {
            cost[1][j][a[i] - 1] =  (i - 1) - Query(0,j) - Query(1,a[i] - 1);
            }
            Insert(1,a[i]);
        }
    }
    for(int i = 0 ; i <= N ; ++i) {
        for(int j = 0 ; j <= N ; ++j) {
            if(i == 0 && j == 0) continue;
            dp[i][j] = 0x7fffffff;
            if(i != 0) {
            dp[i][j] = min(dp[i][j],dp[i - 1][j] + cost[0][i - 1][j]);
            }
            if(j != 0) {
            dp[i][j] = min(dp[i][j],dp[i][j - 1] + cost[1][i][j - 1]);
            }
        }
    }
    printf("%d\n",dp[N][N]);
}
int main() {
    Solve();
}

Measured memory_bytes: 47360
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 n, a, b;
  cin >> n >> a >> b;
  vector<i64> h(n);
  i64 hmax = 0;
  REP(i, n) {
    cin >> h[i];
    hmax = max(hmax, h[i]);
  }

  i64 gap = a - b;
  auto check = [&](i64 cnt) -> bool {
    i64 acnt = 0;
    REP(i, n) {
      i64 rest = h[i] - b * cnt;
      if (rest <= 0) continue;
      acnt += (rest + gap - 1) / gap;
      if (acnt > cnt) return false;
    }
    return true;
  };

  i64 ng = -1, ok = hmax / b + 1;
  while (ok - ng > 1) {
    i64 mid = (ok + ng) / 2;
    if (check(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  cout << ok << endl;
}

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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  
  int ans = 1<<29;
  for (int i = -100; i <= 100; i++) {
    int sum = 0;
    for (int j = 0; j < n; j++) {
      sum += (i - a[j]) * (i - a[j]);
    }
    ans = min(ans, sum);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 764
n = int(input())
a = list(map(int,input().split()))
cnt1 = cnt2 = cnt3 = cnt4 = cnt5 = cnt6 = cnt7 = cnt8 = cnt9 = 0
for num in a:
  if 1<=num<400:
    cnt1 += 1
  elif 400<=num<800:
    cnt2 += 1
  elif 800<=num<1200:
    cnt3 += 1 
  elif 1200<=num<1600:
    cnt4 += 1   
  elif 1600<=num<2000:
    cnt5 += 1 
  elif 2000<=num<2400:
    cnt6 += 1
  elif 2400<=num<2800:
    cnt7 += 1
  elif 2800<=num<3200:
    cnt8 += 1
  else:
    cnt9 += 1
cnt = [cnt1,cnt2,cnt3,cnt4,cnt5,cnt6,cnt7,cnt8]

ans = 0
for c in cnt:
  if c != 0:
    ans += 1

print(max(ans,1),ans+cnt9)    


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    int a, b[n];
    rep(i,n) b[i] = k;
    rep(i,q){
        cin >> a;
        b[a-1]++;
    }
    rep(i,n){
        b[i] -=q;
        if(b[i] > 0) cout << "Yes" << endl;
        else  cout << "No" << endl;
    }
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

  

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

  cout << (x-a)%b << endl;    
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	cout << fixed << setprecision(18);

	ll n, p;
	cin >> n >> p;
	
	vector<ll> a(n);
	ll count_o, count_e;
	count_o = count_e = 0;
	rep(i, n)
	{
		cin >> a[i];
		if (a[i] % 2 == 0)
			count_e++;
		else
			count_o++;
	}

	if (n == 1)
	{
		if (p == 0 && count_e == 0)
			cout << 0 << endl;
		else if (p == 1 && count_o == 0)
			cout << 0 << endl;
	}
	else
	{
		if (p == 1 && count_o == 0)
			cout << 0 << endl;
		else if(p == 0 && count_o == 0)
			cout << (ll)pow(2, n) << endl;
		else
			cout << (ll)pow(2, n - 1) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(int argc, const char * argv[]){
    int i, dice[6] = {0}, d;
    char direction[101];
    for( i = 0 ; i < 6 ; i++ ) {
        scanf("%d", &dice[i]);
    }
    scanf("%s",direction);
    for( i = 0 ; direction[i] != '\0' ; i++) {
        
        if( direction[i] == 'E'){
            d = dice[0];
            dice[0] = dice[3];
            dice[3] = dice[5];
            dice[5] = dice[2];
            dice[2] = d;
        }
        else if( direction[i] == 'N'){
            d = dice[0];
            dice[0] = dice[1];
            dice[1] = dice[5];
            dice[5] = dice[4];
            dice[4] = d;
        }
        else if( direction[i] == 'S'){
            d = dice[0];
            dice[0] = dice[4];
            dice[4] = dice[5];
            dice[5] = dice[1];
            dice[1] = d;
        }
        else if( direction[i] == 'W'){
            d = dice[0];
            dice[0] = dice[2];
            dice[2] = dice[5];
            dice[5] = dice[3];
            dice[3] = d;
        }
    }
    printf("%d\n",dice[0]);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define f first
#define s second
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(...) cout << " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " << endl
 
using ld = long double;
using ll = long long;
using pii = pair <int,int>;
using pll = pair <ll,ll>;
using vi = vector <int>;
using vll = vector <ll>;
using vpii = vector <pii>;
using vpll = vector<pll>;
using vs = vector <string>;
 
vs grid;
vector <vi> magics;
int H,W;
const int INF = 1e9 + 7;

bool valid(int i,int j){
  return i >= 0 && i < H && j >= 0 && j < W  && grid[i][j] == '.';
}
 
int main(){
  fastio;
 
  cin >> H >> W;
 
  int Ch,Cw;
  cin >> Ch >> Cw;
  int Dh, Dw;
  cin >> Dh >> Dw;
  Ch--, Cw--, Dh--, Dw--;
 
  grid.resize(H);
  magics.assign(H,vi(W,INF));
 
  for(int i=0;i<H;i++)
    cin >> grid[i];
 
  queue <pii> q;
  magics[Ch][Cw] = 0;
  q.push({Ch,Cw});

  int ans = INF;

  while(true){
    vpii vis;

     while(!q.empty()){
      int x = q.front().f;
      int y = q.front().s;
      vis.pb({x,y});
      q.pop();
  
      vpii mov = {{0,1},{0,-1},{1,0},{-1,0}};
  
      for(int k=0;k<4;k++){
        int i = x + mov[k].f;
        int j = y + mov[k].s;
  
        if(valid(i,j) && magics[i][j] > magics[x][y]){
          magics[i][j] = magics[x][y];
          q.push({i,j});
        }
      } 
    }

    ans = magics[Dh][Dw];
 
    if(ans == INF)
      ans = -1;

    if(ans != -1)
      break;

    bool can = false;

    for(auto p:vis){
      int x = p.f;
      int y = p.s;
      for(int k=-2;k<=2;k++)
      for(int l=-2;l<=2;l++){
        int i = x + k;
        int j = y + l;
        if(valid(i,j) && magics[i][j] > magics[x][y] + 1){
          magics[i][j] = magics[x][y] + 1;
          q.push({i,j});
          can = true;
        }
      }
    }

    if(!can)
      break;
  }
 
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 8744
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def dfs(G, i):
    seen = set([i])
    stack = [i]
    cnt = 0
    while stack:
        node = stack.pop()
        cnt += 1
        for _n in G[node]:
            if _n not in seen:
                seen.add(_n)
                stack.append(_n)
    return cnt


def main():
    from collections import defaultdict
    G = defaultdict(set)
    edge = []
    n, m = input_int_list()

    for _ in range(m):
        a, b = input_int_list()
        G[a].add(b)
        G[b].add(a)
        edge.append((a, b))

    ans = 0
    # すべての辺を取り除いたときに、dfsで全ノードを辿れるか調べる
    # O(n*m)
    for a, b in edge:
        G[a].remove(b)
        G[b].remove(a)
        cnt = dfs(G, 1)
        if cnt < n:
            ans += 1
        G[a].add(b)
        G[b].add(a)

    print(ans)

    return


if __name__ == "__main__":
    main()


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int min = 0;
  
  if (a > b) {
    min += b;
  }
  else {
    min += a;
  }
  
  if (c > d) {
    min += d;
  }
  else {
    min += c;
  }
  
  cout << min << endl;
}

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

int H, W, K;
matrix S, ans;
vector<int> a;

void input() {
    cin >> H >> W >> K;
    S = matrix(H);
    rep(i, H) {
        bool flag = false;
        rep(j, W) {
            char c;
            cin >> c;
            if (c == '#') {
                S[i].push_back(j);
                flag = true;
            }
        }
        S[i].push_back(W);
        if (flag) a.push_back(i);
    }
    a.push_back(H);
}

void insert_ans(pair<int, int> x, pair<int, int> y, int& k) {
    for (int i = x.first; i < x.second; i++) {
        for (int j = y.first; j < y.second; j++) {
            ans[i][j] = k;
        }
    }
    k++;
}

int main() {
    input();
    int k = 1;
    pair<int, int> x, y;
    ans = matrix(H, vector<int>(W));
    x.first = 0;
    for (int i = 0; i < a.size()-1; i++) {
        x.second = a[i+1];
        y = make_pair(0, S[a[i]][1]);
        insert_ans(x, y, k);
        for (int j = 2; j < S[a[i]].size(); j++) {
            y = make_pair(S[a[i]][j-1], S[a[i]][j]);
            insert_ans(x, y, k);
        }
        x.first = a[i+1];
    }
    rep(i, H) {
        rep(j, W-1) cout << ans[i][j] << " ";
        cout << ans[i].back() << endl;
    }
}


Measured memory_bytes: 1792
# 高橋君の住む町の天気は、一日ごとに晴れ(Sunny)、くもり(Cloudy)、雨(Rainy)、晴れ、くもり、雨、… と周期的に変化します。
# 今日の天気を表す文字列 S が与えられるので、明日の天気を予測してください。

# 標準入力から明日の天気を表す文字列 S を取得する
today_weather = input()
tommorow_weather = 'I do not know. Sorry!!'

# 取得した入力 S を条件に従い出力する。
if today_weather == 'Sunny':
    tommorow_weather = 'Cloudy'
elif today_weather == 'Cloudy':
    tommorow_weather = 'Rainy'
elif today_weather == 'Rainy':
    tommorow_weather ='Sunny'

print(tommorow_weather)


Measured memory_bytes: 8920
import Control.Applicative
import Data.Bool (bool)

main :: IO ()
main = solve <$> f >>= putStrLn
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> String
solve [x, y] = bool "No" "Yes" $ tbl !! x == tbl !! y
  where
    tbl = [0,0,2,0,1,0,1,0,0,1,0,1,0]


Measured memory_bytes: 508
# 2019/07/16

from heapq import heappop,heappush

n,m=map(int,input().split())
edge=[[] for _ in range(n)]
del_edge=[]
cnt=0

for _ in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    edge[a].append(b)
    edge[b].append(a)
    del_edge.append((a,b))


def find(s,de):
    visited=[False]*n
    visited[s]=True
    que=[]
    for e in edge[s]:
        if s in de and e in de:continue
        heappush(que,e)
    while que: 
        v=heappop(que)
        if visited[v]:continue
        visited[v]=True
        for vtx in edge[v]:
            if v in de and vtx in de:continue
            if visited[vtx]:continue
            hq=vtx
            heappush(que,hq)

    if False in visited:
        return 1
    else:return 0

for i in range(m):
    tmp=del_edge[i]
    cnt+=find(0,tmp)

print(cnt)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int)n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}
 


 
int main(){
	//in_o();
	string s;
	cin>>s;
	MPII hsh;
	FOR(i,0,s.length()){
		hsh[s[i]-'0']++;
	}
	FOREACH(it,hsh){
		if(it->second%2)
			return cout<<"No"<<endl,0;
	}
	return cout<<"Yes"<<endl,0;
}


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

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


#define      TEST    int t ; cin >> t ; while( t -- )

const ll big = 10e7 + 11 ;
const double PI  =3.141592653589793238463;

int  main (  ) {

    FASTIO ;

    double n ;
    cin >> n ;

    double ans = 2 * PI * n ;

    cout << setprecision( 10 ) << fixed << ans ;

    return  0 ;
}


Measured memory_bytes: 3816