akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define inf (1ll<<60) 
#define r register
inline bool isd(r char ch) {
	return ch<='9'&&ch>='0';
}
template<class temp>
inline temp F() {
	r temp x=0;
	r bool bo=0;
	r char ch=getchar();
	while(ch!='-'&&!isd(ch))
		ch=getchar();
	(ch=='-')&&(bo=1,ch=getchar());
	x=ch^'0',ch=getchar();
	while(isd(ch))
		x=(x<<1)+(x<<3)+(ch^'0'),ch=getchar();
	bo&&(x=-x);
	return x;
}
const int mod=998244353;
int Qpow(r int x,r int y) {
	r int ret=1;
	while(y) {
		if(y&1)
			ret=1ll*ret*x%mod;
		x=1ll*x*x%mod,y>>=1;
	}
	return ret;
}
int fac[20001],ifc[20001],inv[20001];
int lim=1,lg=0;
int G[2][25];
int p[100001];
int f[100001],g[100001];
inline int Add(r int a,r int b) {
	return a+b>=mod?a+b-mod:a+b; 
}
inline int Sub(r int a,r int b) {
	return a-b<0?a-b+mod:a-b;
}
inline int Mul(r int a,r int b) {
	return 1ll*a*b%mod;
}
void Calc() {
	for(r int i=0;i<lim;++i)
		p[i]=(p[i>>1]>>1)|((i&1)<<(lg-1));
}
void NTT(int *x,r bool inv) {
	for(r int i=0;i<lim;++i)
		if(i<p[i])
			std::swap(x[i],x[p[i]]);
	for(r int mid=1,o=1;mid<lim;mid<<=1,++o) {
		r int Wn=G[inv][o];
		for(r int t=mid<<1,i=0;i<lim;i+=t)
			for(r int j=0,w=1;j<mid;++j,w=1ll*w*Wn%mod) {
				r int t1=x[i+j],t2=1ll*x[i+j+mid]*w%mod;
				x[i+j]=Add(t1,t2);
				x[i+j+mid]=Sub(t1,t2);
			}
	}
}
inline int C(r int n,r int m) {
	if(n<m)
		return 0;
	return 1ll*fac[n]*ifc[m]%mod*ifc[n-m]%mod;
}
int dp[2][10001];
int main() {
//	freopen("matrix.in","r",stdin);
//	freopen("matrix.out","w",stdout);
	G[0][23]=Qpow(3,119);
	G[1][23]=Qpow(G[0][23],mod-2);
	for(r int i=22;i;--i) {
		G[0][i]=1ll*G[0][i+1]*G[0][i+1]%mod;
		G[1][i]=1ll*G[1][i+1]*G[1][i+1]%mod;
	}
	r int N=F<int>(),M=F<int>();
	fac[0]=fac[1]=ifc[0]=ifc[1]=inv[1]=1;
	for(r int i=2;i<=N+10;++i) {
		fac[i]=1ll*i*fac[i-1]%mod;
		inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
		ifc[i]=1ll*inv[i]*ifc[i-1]%mod;
	}
	r int cur=0;
	for(r int i=0;i<=N;++i)
		dp[cur][i]=1;
	for(r int i=1;i<=N;++i)
		g[i]=ifc[i+2];
	lim=1,lg=0;
	while(lim<=N*2+2)
		lim<<=1,++lg;
	Calc();
	NTT(g,0);
	r int Inv=Qpow(lim,mod-2);
	for(r int i=2;i<=M;++i,cur^=1) {
		memset(dp[cur^1],0,sizeof dp[cur^1]);
		for(r int j=0;j<=N;++j) 
			dp[cur^1][j]=Add(dp[cur^1][j],Mul(dp[cur][j],Add(C(j+1,2),1)));
		memset(f,0,sizeof f);
		for(r int j=0;j<=N;++j)
			f[j]=Mul(dp[cur][j],ifc[j]);
		NTT(f,0);
		for(r int j=0;j<lim;++j)
			f[j]=Mul(f[j],g[j]);
		NTT(f,1);
		for(r int j=0;j<lim;++j)
			f[j]=Mul(f[j],Inv);
		for(r int j=0;j<=N;++j)
			dp[cur^1][j]=Add(dp[cur^1][j],Mul(f[j],fac[j+2]));
	}
	r int ans=0;
	for(r int i=0;i<=N;++i)
		ans=Add(ans,Mul(C(N,i),dp[cur][i]));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n);
  int sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  sort(all(a));
  rep(i,n){
    if(sum%10)break;
    if((sum-a[i])%10){
      sum-=a[i];
      break;
    }
  }
  if(sum%10)
    cout<<sum<<endl;
  else 
    cout<<0<<endl;
}


Measured memory_bytes: 256
N = gets.to_i
h = gets.split(' ').map(&:to_i)
cnt = 0
while h.max != 0
  l = 0
  while l < N && h[l] == 0 
    l += 1
  end
  r = l
  while r < N && h[r] > 0
    r += 1
  end
  l.upto(r - 1) do |i|
    h[i] -= 1
  end
  cnt += 1
end

puts cnt

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,temp;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b){
        temp=a;
        a=b;
        b=temp;
    }
    if(c>=a&&c<=b){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


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



int solution(int* arr , int n , int k){
    
    int* dp = new int[n];
    for(int i=0 ; i<n ; i++){
        dp[i] = INT_MAX;
    }
    
    dp[0] = 0;

    for(int i=1 ; i<n ; i++){
        for(int j=1 ; j<=k ; j++){
            if((i-j) < 0){
                break;
            }
            dp[i] = min(dp[i] , dp[i-j] + abs(arr[i] - arr[i-j]));
        }
    }
    
    return dp[n-1];
}


int main(){
    int n , k;
    cin>>n>>k;
    int* arr = new int[n];
    for(int i=0 ; i<n ; i++){
        cin>>arr[i];
    }
    cout<<solution(arr , n , k)<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int cnt=0;
  while(b<=a){
   cnt++;
    b*=2;
  }
  while(c<=b){
   cnt++;
    c*=2;
  }
  if(cnt<=k)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3556
S = input()
akb = 'AKIHABAR'
if len(S) <= len(akb)+1:
  i = 0
  for a in akb:
    if i >= len(S):
      print('NO')
      exit()
    if S[i] == a: i+=1
    elif S[i] != a and a == 'A': continue
    else:
      print('NO')
      exit()
  print('YES')
else:
  print('NO')



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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b,h,m;
    long double c;
    
    cin>>a>>b>>h>>m;
    
    c=sqrt(a*a+b*b-2*a*b*cos(((60*h-11*m)*M_PI)/360));
    cout<<fixed<<setprecision(20)<<c<<"\n";
    return 0;
}

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

int main(){
  int n;
  cin >>n;
  vector <ll> a(n);
  rep(i,n)cin >>a.at(i);

  ll maxv = -2000000000;
  ll minv = a.at(0);

  for(int i =1;i<n;i++){
    maxv = max(maxv,(a.at(i)-minv));
    minv = min(minv,a.at(i));
  }
  cout <<maxv<<endl;
}


/*
//時間外になってしまう
int main(){
  int n;
  cin >>n;
  vector <int> a(n);
  rep(i,n)cin >>a.at(i);
  ll dmax = -1000000000;

  for (int i = 1;i<n;++i){
    int x= a.at(i);//新しい大きいのが好ましい数
    sort(a.begin(),(a.begin()+(i)));//選択した数字より前の値をソート
    ll dif = x - a.at(0);
    //cout <<"a.at(0)= "<<a.at(0)<<"dif = "<<dif<<endl;
    dmax = max(dmax,dif);

  }
  cout<<dmax<<endl;
}
*/



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

using namespace std;

int main(){
    int N,M;
    cin >> N;
    vector<int> T(N);
    for(int i=0; i<N;i++)cin >> T[i];
    cin >> M;

    int sum =0;
    int P,X;
    for(int i=0; i<N; i++)sum+=T[i];
    for(int i=0; i<M; i++){
        cin >> P >> X;
        cout << sum - T[P-1] + X << endl;
    }
    
}

Measured memory_bytes: 256
n,k=map(int,input().split())
L=[]
R=[]
h=[0,1,-1]+[0]*400010
M=998244353
for i in range (k):
    l,r=map(int,input().split())
    L.append(l)
    R.append(r)
N=0
for i in range (1,n):
    N=(N+h[i]+100*M)%M
    for j in range (k):
        h[L[j]+i]+=N
        h[R[j]+i+1]-=N
print(((N+h[n])+100*M)%M)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef vector<ii> vii;

#define solve imAwesome
#define for0(i,n) for(int i=0; i<(int)n; i++)
#define forn(i,n) for(int i=1; i<=(int)n; i++)
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define all(x) x.begin(),x.end()
#define endl cout << "\n";
#define debug cout << "Aqui\n";
#define deb(i) cout << "Aqui " << (ll) i << "\n";
#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	
	map <int,string> m;
	string s;
	cin >> s;
	reverse(all(s));
	m[5]=m[7]=m[9]=m[4]=m[2]="hon";
	m[3]="bon"; 
	m[0]=m[1]=m[6]=m[8]="pon";
	cout << m[s[0]-'0'] << "\n";
	
	return 0;

}


Measured memory_bytes: 3652
package main

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

func main() {
	N, K := ReadInt(), ReadInt()
	as := ReadInts(N)
	dp := make([]bool, K+1)
	for i := 1; i < K+1; i++ {
		for _, a := range as {
			if i-a >= 0 && !dp[i-a] {
				dp[i] = true
				break
			}
		}
	}
	if dp[K] {
		fmt.Println("First")
	} else {
		fmt.Println("Second")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1956
#include <stdio.h>
#include <string.h>
int main(){
    char s, a[128] = {0};
    int i = 0, n;
    while(scanf("%c", &s) != EOF){
        if (s >= 'A' && s <= 'Z')
        {
            s = s + 32;
        }
        a[s] = a[s] + 1;
        i++;
    } while (s != '\n');
    for (int i = 'a'; i <= 'z'; i++)
    {
        printf("%c : %d\n", i, a[i]);
    }
    return 0;
}


Measured memory_bytes: 2048
// https://atcoder.jp/contests/abc061/tasks/abc061_d
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

template <typename T> struct edge {
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x) {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

template <typename T> vector<T> bellman_ford(Edges<T> &edges, int V, int s) {
    const auto INF = numeric_limits<T>::max();
    vector<T> dist(V, INF);
    dist[s] = 0;
    for (int i = 0; i < V; i++) {
        for (auto &e : edges) {
            if (dist[e.src] == INF)
                continue;
            if (dist[e.to] > dist[e.src] + e.cost) {
                dist[e.to] = dist[e.src] + e.cost;
                if (i == V - 1 && e.to == V - 1) {
                    return vector<T>();
                }
            }
        }
    }
    // for (auto &e : edges) {
    //     if (dist[e.src] == INF)
    //         continue;
    //     if (dist[e.src] + e.cost < dist[e.to])
    //         return vector<T>();
    // }
    return dist;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    Edges<ll> es;
    REP(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        es.emplace_back(a - 1, b - 1, -c);
    }
    auto dists = bellman_ford(es, N, 0);
    if (dists.size() == 0) {
        cout << "inf\n";
    } else {
        cout << -dists.back() << "\n";
    }

    return 0;
}


Measured memory_bytes: 384
def main():
    n = int(input())
    xy = [list(map(int, input().split())) for _ in [0]*n]
    z1 = [x+y for x, y in xy]
    z2 = [x-y for x, y in xy]
    z3 = [-x+y for x, y in xy]
    z4 = [-x-y for x, y in xy]
    print(max([max(z1)-min(z1), max(z2)-min(z2),
               max(z3)-min(z3), max(z4)-min(z4)]))


main()


Measured memory_bytes: 124208
n, x, y = [int(c) for c in input().split()]

d = {i : 0 for i in range(1,n)}
for i in range(1,n+1):
    for i2 in range(i+1, n+1):
        dist = min(i2 - i, abs(x-i) + 1 + abs(y-i2))
        d[dist] += 1
for v in d.values():
    print(v)

Measured memory_bytes: 3572
#include <stdio.h>
#define MAX 600


int blaue[MAX];
int rote[MAX];

int c[MAX][MAX];
int p[MAX];//rote->blaue

int gcd(int x,int y)
{
    while(y!=0)
    {
        int r=x%y;
        x=y;
        y=r;
    }
    return x;
}

int match(int m,int n,int *v,int bn)
{
    if(bn<0)return 1;
    for(int j=0;j<n;j++)
    {
        if(c[bn][j]==0 || v[j])continue;
        v[j]=1;
        if(match(m,n,v,p[j]))//if p[j]==-1, the result is true(1)
        {
            p[j]=bn;
            return 1;
        }
    }
    return 0;
}


int main(void)
{
    int m,n;
    while(scanf("%d%d",&m,&n)==2&&(m||n))
    {
        for(int i=0;i<m;i++)
        {
            scanf("%d",blaue+i);
        }
        for(int j=0;j<n;j++)
        {
            scanf("%d",rote+j);
            p[j]=-1;
        }
        for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;++j)
            {
                c[i][j]=gcd(blaue[i],rote[j])>=2?1:0;
            }
        }
        int result=0;
        for(int i=0;i<m;i++)
        {
            int v[MAX]={0};
            result+=match(m,n,v,i);
        }
        printf("%d\n",result);
    }
    
}

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

using namespace std;

const int maxn = 2100;

int n,k,q,a[maxn],res;
vector<int> bigger;
multiset<int> ans;

int main() {
   // freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k>>q;
    res = 1e9;
    for (int i=1;i<=n;i++) cin>>a[i];
    for (int mi=1;mi<=n;mi++) {
        ans.clear();
        bigger.clear();
        for (int i=1;i<=n+1;i++)
            if (i==n+1 || a[i] < a[mi]) {
                //cout<<(int)bigger.size() - k<<endl;
                sort(bigger.begin(),bigger.end());
                for (int ii = 0; ii<= (int)bigger.size()-k; ii++) ans.insert(bigger[ii]);
                bigger.clear();
            } else bigger.push_back(a[i]);
       // cout<<ans.size()<<endl;
        if (ans.size() < q) continue;
        auto it = ans.begin();
        for (int i=1;i<q;i++) it++;
        res = min(res,*it - a[mi]);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 384
import java.util.*;
import java.text.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		ArrayList<Integer> card = new ArrayList<Integer>();
		ArrayList<Integer> take = new ArrayList<Integer>();
		while(true){
			int n = in.nextInt();
			int r = in.nextInt();
			if(n==0 && r==0) break;
			for(int i=0; i<n; i++){
				card.add(n-i);
			}
			for(int i=0; i<r; i++){
				int p = in.nextInt();
				int c = in.nextInt();
				for(int j=0; j<p-1; j++){
					take.add(card.get(j));
				}
				for(int j=0; j<c; j++){
					card.set(j, card.get(j+p-1));
				}
				for(int j=0; j<p-1; j++){
					card.set(j+c, take.get(j));
				}
				take.clear();
			}
			System.out.println(card.get(0));
			card.clear();
		}
	}
}

Measured memory_bytes: 12000
n = int(input())
t, a = map(int, input().split())
H = list(map(int, input().split()))

ansindex = 0
mindelta = 100000
for i, h in enumerate(H):
	average = t - h * 0.006
	delta = abs(a - average)
	if delta < mindelta:
		ansindex = i + 1
		mindelta = delta

print(ansindex)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {

            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            if (m == -1 && f == -1 && r == -1) {
                break;
            } else if (m == -1 || f == -1) {
                System.out.println("F");
            } else if (m + f >= 80) {
                System.out.println("A");
            } else if (65 <= m + f && m + f < 80) {
                System.out.println("B");
            } else if (50 <= m + f && m + f < 65) {
                System.out.println("C");
            } else if (30 <= m + f && m + f < 50) {
                if (r >= 50) {
                    System.out.println("C");
                } else {
                    System.out.println("D");
                }
            } else if (m + f < 30) {
                System.out.println("F");
            }
        }
    }
}



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

main() {
  int N,M,X;
  cin >> N >> M >> X;
  
  vector<int> gate(M);
  vector<bool> stamp(N+1,false);
  
  for(int i=0; i<M; i++){
    cin >> gate[i];
    stamp[gate[i]] =true;
  }
  
  int left=0,right=0;
  
  for(int i=0; i<X; i++){
    if(stamp[i])
      left++;
  }
  
  for(int j=N; j>X; j--){
    if(stamp[j])
      right++;
  }
  
  cout << min(left,right) << endl;
  return 0;
}  

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

class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n;
	int w;
	int[] h;

	void run(){
		for(;;){
			n=sc.nextInt();
			w=sc.nextInt();
			if((n|w)==0){
				break;
			}
			h=new int[20];
			int vMax=0;
			int hMax=0;
			for(int i=0; i<n; i++){
				int v=sc.nextInt();
				h[v/w]++;
				vMax=Math.max(vMax, v);
				hMax=Math.max(hMax, h[v/w]);
			}
			int m=vMax/w+1;
			double ans=0;
			debug("test");
			for(int i=0; i<m; i++){
				double a=(double)(m-1-i)/(m-1);
				double b=(double)h[i]/hMax;
				ans+=a*b;
				debug("i", i);
				debug("a", a);
				debug("b", b);
			}
			ans+=0.01;
			println(""+ans);
		}
	}

	void debug(Object... os){
	// System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		try{
			// System.setIn(new FileInputStream("in.txt"));
		}catch(Throwable e){
			e.printStackTrace();
		}
		new Main().run();
	}
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int s = 1;
    rep(i, N) {
        if (A[i] == s) {
            s++;
        }
    }

    if (s == 1) {
        cout << -1 << endl;
    } else {
        cout << N - (s - 1) << endl;
    }
}

Measured memory_bytes: 1024
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 INT_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 INT_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<int>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
int main()
{
	ll k,x;
	cin>>k>>x;

	if((500*k)>=x)
		cout<<"Yes\n";
	else
		cout<<"No\n";


	return 0;
}

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

int main(void) {
    int N;
    string S;

    cin >> N;
    cin >> S;

    long long r_cnt = 0;
    long long g_cnt = 0;
    long long b_cnt = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') r_cnt++;
        if (S[i] == 'G') g_cnt++;
        if (S[i] == 'B') b_cnt++;
    }
    long long pat1 = r_cnt * g_cnt * b_cnt;

    /* i, j , kが等間隔でない、文字かぶりが発生しているものをカウント. */
    long long n_pat2 = 0;
    for (int i =0; i<N; i++) {
        for (int j = i+1; j < N; j++) {
            if (S[i] == S[j]) continue;
            int k = 2 * j - i;
            if (k >= N) continue;
            if ((S[i] == S[k]) || S[j] == S[k]) continue;
            n_pat2++;
        }
    }

    cout << pat1 - n_pat2 << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	
	int maxt=0,maxn=0;
	double maxc=0;
	a=a*100,b=b*100;
	double t=(double)e/(100+e);
	
	for(int i=0;i<=3000;i++)
	{
		if(i*c<=f)
		for(int j=0;j<=3000;j++)
		{
			if(i*c+j*d<=f)
			{
				for(int k=0;k<=30;k++)
				{
					for(int l=0;l<=30;l++)
					{
						if(i*c+j*d+k*a+l*b!=0&&i*c+j*d+k*a+l*b<=f)
						{ 
							double t1=(double)(i*c+j*d)/(i*c+j*d+k*a+l*b);
							if(t1<=t&&t1>=maxc)
							{
								maxc=t1;
								maxt=i*c+j*d+k*a+l*b;
								maxn=i*c+j*d;
								//cout<<i<<' '<<j<<' '<<' '<<k<<' '<<l<<endl; 
							}
					    }
					}
				}
			}
		}
	}	
	
	cout<<maxt<<' '<<maxn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int d_x[4] = { -1,0,1,0 };
int d_y[4] = { 0,1,0,-1 };

int t[3][3];
int level=0;

int countpath() {
	int ret=0;
	int tmp;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (t[i][j] != 0) {
				tmp = t[i][j] - 1;
				ret += abs(tmp / 3 - i) + abs(tmp % 3 - j);
			}
		}
	}
	return ret;
}

bool check(int depth, int pre, int px, int py) {
	int w = countpath();
	if (w + depth > level) return false;
	if (w == 0)return true;
	int dx, dy;
	for (int i = 0; i < 4; i++) {
		if (abs(i - pre) != 2) {
			dx = px + d_x[i];
			dy = py + d_y[i];
			if (dx < 0 || dx == 3 || dy < 0 || dy == 3) continue;
			swap(t[dx][dy], t[px][py]);
			if (check(depth + 1, i, dx, dy)) return true;
			swap(t[dx][dy], t[px][py]);
		}
		
	}
	return false;
}

void solution(int px, int py) {
	for (level = 0;; level++) {
		if (check(0, 9, px, py)) {
			cout << level << endl;
			return;
		}
	}
}

int main() {
	int px, py;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> t[i][j];
			if (t[i][j] == 0) {
				px = i;
				py = j;
			}
		}
	}
	solution(px,py);
	return 0;
}

Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		double a = scn.nextInt(), b = scn.nextInt(), x = scn.nextInt();
		if(x <= a*a*b/2) {
			double h = x/(a*b)*2;
			System.out.println(90.0-Math.atan2(h, b)/Math.PI*180);
		}else {
			double h =(a*b*a-x)/(a*a)*2;
			System.out.println(Math.atan2(h,a)/Math.PI*180);
		}
	}

}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;

map<string, int> mp;

void solve (){
	string a;
	cin >> a;
	mp[a]++;
}

int32_t main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	int tc = 1;
	cin >> tc;
	while(tc--)
		solve();
	
	string mapa[4] = {"AC", "WA", "TLE", "RE"};
	for(int i = 0; i < 4; i++){
		cout << mapa[i] << " x " << mp[mapa[i]] << endl;
	}
}


Measured memory_bytes: 3668
#include<iostream>
using namespace std;
 
int main(){
    int n,i;

    while(1){
        int point[100]={0,};
        int min = 1000;
        int max = 0;
		long total = 0;
        cin >> n;
        if(!n) break;
        for(i=0;i<n;i++){
            cin >> point[i];
            if(point[i] > max) max = point[i];
            if(point[i] < min) min = point[i];
			total += point[i];
        }
        cout << (total-max-min)/(n-2) << "\n";
    }

}

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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int n = 4 ;
  string s ;
  cin >> s ;
  
  if(s.at(0)==s.at(1) || s.at(1)==s.at(2) || s.at(2)==s.at(3)){
    cout <<"Bad"<<endl ;
  }
  else{
    cout <<"Good"<<endl ;
  }
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
import sys
import math
n, m = (int(i) for i in input().split())
l=abs(n-m)
div=int(10**9+7)

if l>1:
    print(0)
    sys.exit()

if l==1:
    ans=(math.factorial(n)*math.factorial(m))%div
    print(ans)
else:
    ans=(math.factorial(n)*math.factorial(m)*2)%div
    print(ans)


Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if (true)
#else
#define dout   \
	if (false) \
	cout
#define debug() if (false)
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力
#define vec(v, n) vector<int> v(n, 0);
typedef long long ll;
typedef unsigned long long ull;
void Main()
{
	int N;
	cin>>N;
	vec(A, N+1);
	vec(B, N);
	vin(A);
	vin(B);
 
	ll ans = 0;
 
	rep(i,N){
		if(B[i] > A[i]){
			ans += A[i];
			B[i] -= A[i];
 
			if(B[i]>A[i+1]){
				ans += A[i+1];
				A[i+1] = 0;
			}
			else{
				ans += B[i];
				A[i+1] -= B[i];
			}
 
		}
		else{
			ans += B[i];
		}
	}
 
	cout<<ans<<endl;
}
 
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,K;
int A[2020];
int C[2020];
ll mo=1000000007;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) {
		cin>>A[i];
		C[A[i]]++;
	}
	
	ll ret=0;
	FOR(y,N) FOR(x,y) if(A[x]>A[y]) ret+=K;
	ret%=mo;
	
	FOR(i,N) {
		ll sum=0;
		FOR(j,A[i]) sum+=C[j];
		ret+=((K-1)*K/2)%mo*sum%mo;
	}
	cout<<ret%mo<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#! /usr/bin/env ruby

n = gets.chomp.to_i
s = gets.chomp
k = gets.chomp.to_i

a = s[k-1]


result = ""

n



s.chars.each do |i|
  if(s[i] == a)
    result += a
  else
    result += "*"
  end
end
 
puts result



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

int main(){

    while(1){
        int n, p;
        cin >> n >> p;
        if(n == 0){
            break;
        }

        vector<int> cnt(n, 0);

        int i = 0;
        int stone = p;
        while(1){

            if(stone == 0){
                stone += cnt[i];
                cnt[i] = 0;
            }
            else{
                stone--;
                cnt[i]++;
            }

            if(stone == 0 && cnt[i] == p){
                break;
            }

            i++;
            if(i == n){
                i = 0;
            }
        }

        cout << i << endl;
    }

    return 0;
}


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

int main(){
	int n;
	cin>>n;
	int a=0;
	vector<int> s(2*n);
	for(int i=0;i<2*n;i++){
		cin>>s[i];
	}
	sort(s.begin(),s.end());
	for(int i=0;i<2*n;i+=2){
		a+=min(s[i],s[i+1]);
	}
	cout<<a<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int g = sc.nextInt();
        int[] p = new int[d];
        int[] c = new int[d];
        for (int i =0; i<d; i++) {
            p[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        int min =1001; int count =0; int ans =0;
        for (int i =0; i<Math.pow(2,d); i++) {
            String s = String.format("%" + d + "s", Integer.toBinaryString(i)).replace(' ', '0');
            int n = s.length();
            for (int j=0; j<n; j++) {
                if (s.charAt(j) == '1' ) {
                    count += p[j] * (j + 1) * 100 + c[j];
                    ans += p[j];
                }
            }
            if (count<g) {
                for (int j=n-1; j>=0; j--) {
                    if (s.charAt(j) == '0' ) {
                        int l = p[j];
                        while (count < g && l > 0) {
                            count += (j + 1) * 100;
                            ans++;
                            l--;
                        }
                    }
                }
            }
            if (count >= g) {
                min = Math.min(ans,min);
            }
            count =0;
            ans =0;
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 44492
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int h[]=new int[n];

		int dp[]=new int[n];
		for(int i=0;i<n;i++) {
			h[i]=scan.nextInt();
			dp[i]=Integer.MAX_VALUE;
		}
		scan.close();

		dp[0]=0;

		for(int i=1;i<n;i++) {
			dp[i]= dp[i - 1] + Math.abs(h[i] - h[i - 1]);
	        if (i > 1) dp[i]=Math.min(dp[i],  dp[i - 2] + Math.abs(h[i] - h[i - 2]));
		}

		System.out.println(dp[n-1]);
	}

}

Measured memory_bytes: 61088
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {
	ll match[3][3][5000] = {};

	string S[3];
	ll L[3];
	rep(i, 3) {
		cin >> S[i];
		L[i] = S[i].size();
	}

	rep(i, 3) {
		rep(j, 3) {
			if (i == j) { continue; }

			rep(k, 5000) {
				ll b = 1;
				rep(l, min(L[i] - k, L[j])) {
					if (S[i][l + k] != '?'&&S[j][l] != '?'&&S[i][l + k] != S[j][l]) {
						b = 0;
						break;
					}
				}

				if (b == 1) { match[i][j][k] = 1;}
			}
		}
	}

	ll ans = INF;

	vector<ll> p(3);
	rep(i, 3) { p[i] = i; }

	do {
		ll a = p[0];
		ll b = p[1];
		ll c = p[2];

		rep(i, 5000) {
			rep(j, 5000) {
				if (match[a][b][i] == 1 && match[b][c][j] == 1 && match[a][c][i + j] == 1) {
					ll v = max(L[a], max(i + L[b], i + j + L[c]));
					ans = min(v, ans);
				}
			}
		}
	} while (next_permutation(p.begin(),p.end()));

	cout << ans;


	system("PAUSE");

}





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

using namespace std;
typedef long long int ll;
int main() 
{

ll r;
cin>>r;

long double a = (2.0)*(3.1415926535)*(r);
    
    cout.setf(ios::fixed,ios::floatfield);
    cout.precision(10);
    
cout<<a;

    

    return 0;
}


Measured memory_bytes: 3744
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define CL clear()







int main()
{
    vector<int> p, q;
    p.CL;
    p.PB(0);
    q.CL;
    q.PB(0);

    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int r;
        cin >> r;
        p.PB(r);
    }
  for(int i = 0; i < n; i++)
    {
        int r;
        cin >> r;
        q.PB(r);
    }

    int m =0 ;
    int t =n;
    while(t)
    {
        int r = 0;
        int i ;
        for(i = 1; i <= t; i++)
            r += p[i];
        i--;
        for(; i<=n; i++)
            r+=q[i];
        m = max(m, r);
        t--;
    }
    cout << m;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();

		long result = 0;

		if(B >= (C + 1)) {
			result = B + C;
		} else {
			result = 2 * B;

			if((C - B) >= (A + 1)) {
				result += A + 1;

			} else {
				result += (C - B);
			}
		}

		System.out.println(result);

	}

}



Measured memory_bytes: 23764
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <limits>
#include <vector>
#include <algorithm>
#include <functional>
#include <cctype>
#include <sstream>

typedef long long lint;

using namespace std;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);++i)
#define all(x) (x).begin(),(x).end()
#define sl(c) (('a')<=(c)&&(c)<=('z'))
#define ll(c) (('A')<=(c)&&(c)<=('Z'))
#define acout (cout<<fixed<<setprecision(15))
#define makeupper(t) (transform(all(t),t.begin(),::toupper))
#define makelower(t) (transform(all(t),t.begin(),::tolower))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
lint* arr1(lint x) {
	lint *array = new lint[x];
	rep(i, x)array[i] = 0;
	return array;
}
lint** arr2(lint x, lint y) {
	lint **array = new lint*[x];
	rep(i, x)array[i] = new lint[y];
	rep(i, x)rep(j, y)array[i][j] = 0;
	return array;
}
vector<string> split(const string &s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;
	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}
	return elems;
}

int main() {
	double a[4];
	rep(i, 4)cin >> a[i];
	acout << dist(a[0],a[1],a[2],a[3]);
}


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

int main() {
    string s;
    cin >> s;
    int sz = s.size();
    int count = 0;
    for(int i = 0, j = sz-1; i <= sz/2 && j >= sz/2; i++, j--){
        if(s[i] != s[j]){
            count++;
        }
        
    }
    cout << count << endl;
    
	return 0;
}

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

using namespace std;

void String_Compare(int &cnt, int &cnt_R, std::string buf, unsigned int &i);
void Consecutive_Cnt_Update(int &cnt_max, int &cnt_R);

int main()
{
	int cnt_max = 0;
	int cnt_R = 0;
	
	std::string buf;
	std::cin >> buf;

	for (unsigned int i = 0; i < buf.length(); i++)
	{
		String_Compare(cnt_max, cnt_R, buf, i);
	}

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

void String_Compare(int &cnt_max, int &cnt_R, std::string buf, unsigned int &i)
{
	if ('R' == buf[i])
	{
		cnt_R++;
		Consecutive_Cnt_Update(cnt_max, cnt_R);
		return;
	}
	if ('S' == buf[i])
	{
		Consecutive_Cnt_Update(cnt_max, cnt_R);
		cnt_R = 0;
		return;
	}
	cnt_R = 0;
}

void Consecutive_Cnt_Update(int &cnt_max, int &cnt_R)
{
	if (cnt_max < cnt_R)
	{
		cnt_max = cnt_R;
	}
}

Measured memory_bytes: 3596
n, k = list(map(int, input().split()))
s = input()

if n == 1:
    print(0)
    exit()

ans = 0
if s[0] == "R" and s[1] == "R":
    ans += 1
if s[n-1] == "L" and s[n-2] == "L":
    ans += 1

hanten = 0
for i in range(1, n-1):
    if s[i] == "L":
        if s[i-1] == "L":
            ans += 1
    else:
        if s[i+1] == "R":
            ans += 1
    if s[i-1] != s[i]:
        hanten += 1

if s[n-1] != s[n-2]:
    hanten += 1

if k <= hanten // 2:
    print(ans + k*2)
else:
    print(ans + hanten)



Measured memory_bytes: 3316
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M, S = LI()
    G = [[[] for _ in range(2501)] for _ in range(N)]

    for i in range(M):
        u, v, a, b = LI()
        u -= 1
        v -= 1
        for money in range(2501):
            if money - a < 0 :
                continue
            G[u][money].append((b, v, money - a))
            G[v][money].append((b, u, money - a))

    for i in range(N):
        c, d = LI()
        for money in range(2501):
            new_money = min(2500, money + c)
            G[i][money].append((d, i, new_money))
    def dijkstra(u, s):
        q = []
        d = [[inf for __ in range(2501)] for _ in range(N)]
        visited = set()
        dist = 0
        money = min(2500, s)
        d[u][money] = dist
        heapq.heappush(q, (dist, u, money))
        while len(q) > 0:
            dist, u, u_money = heapq.heappop(q)

            if (u, u_money) in visited:
                continue
            visited.add((u, u_money))
            for next_node_tuple in G[u][u_money]:
                cost, v, v_money = next_node_tuple
                if dist + cost < d[v][v_money]:
                    d[v][v_money] = dist + cost
                    heapq.heappush(q, (d[v][v_money], v, v_money))
        return d
    d = dijkstra(0, S)
    for i in range(1, N):
        print(min(d[i]))

main()



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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define PRINT(s) cout<<s
#define PRINTS(s) cout<<s<<' '
#define PRINTL(s) cout<<s<<endl
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int h,w;
    cin>>h>>w;

    string s[h];
    for(int i=0;i<h;i++)cin>>s[i];

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

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                cout<<'#';
                continue;
            }
            else{
                int ans = 0;
                for(int k=0;k<9;k++){
                    int x = j + dx[k];
                    int y = i + dy[k];
                    if(x<0||y<0||x>w-1||y>h-1)continue;
                    else if(s[y][x]=='#')ans++;
                }
                cout<<ans;
            }
        }
        cout<<endl;
    }

    return 0;
}




Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<unordered_set>
#define MAX 4010
using namespace std;
char x[MAX];
int main(){
	int n;
	scanf("%d",&n);
	scanf("%s",x);
	long long cnt=0;
	unordered_set<int> r;
	unordered_set<int> g;
	unordered_set<int> b;
	for(int i=0;i<n;i++){
		if(x[i]=='R') r.insert(i+1);
		else if(x[i]=='G') g.insert(i+1);
		else b.insert(i+1);
	} 
	cnt=r.size()*g.size()*b.size();
	
	for(auto i:r){
		for(auto k:g){
			if((i+k)%2==0){
				if(b.find((i+k)/2)!=b.end()) cnt--;
			}
		}
	}
	
	for(auto i:r){
		for(auto k:b){
			if((i+k)%2==0){
				if(g.find((i+k)/2)!=g.end()) cnt--;
			}
		}
	}
	
		
	for(auto i:g){
		for(auto k:b){
			if((i+k)%2==0){
				if(r.find((i+k)/2)!=r.end()) cnt--;
			}
		}
	}


	printf("%lld",cnt);
	return 0;
}


Measured memory_bytes: 3916
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String deck = scan.nextLine();
        while(!deck.equals("-")) {
            int a = scan.nextInt();
            for(int x = 0; x < a; x++){
                int s = scan.nextInt();
                String half = deck.substring(0, s);
                String rest = deck.substring(s);
                deck = rest + half;
            }
            System.out.println(deck);
            deck = scan.nextLine();
            deck = scan.nextLine();
        }
    }
}


Measured memory_bytes: 26472
(N, _), *edges = [map(int, s.split()) for s in open(0)]
graph = {i: [] for i in range(N)}
for a, b in edges:
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
print("\n".join(str(len(graph[i])) for i in range(N)))


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        
        while (in.hasNextLine()) {
            int R = in.nextInt();
            int C = in.nextInt();
            if (R == 0 && C == 0) break;
            
            HashMap<Character, Loc> hm = new HashMap<Character, Loc>();
            
            for (int i = 0; i < R; i++) {
                String str = in.next();
                for (int j = 0; j < C; j++) {
                    char c = str.charAt(j);
                    if (c == '_') continue;
                    hm.put(c, new Loc(i, j));
                }
            }
            
            String str = in.next();
            
            int iPos = 0;
            int jPos = 0;
            int count = str.length();
            for (int i = 0; i < str.length(); i++) {
                Loc loc = hm.get(str.charAt(i));
                count += Math.abs(iPos - loc.i) + Math.abs(jPos - loc.j);
                iPos = loc.i;
                jPos = loc.j;
            }
            
            System.out.println(count);
        }
    }
    
    public static class Loc {
        int i;
        int j;
        
        public Loc(int i, int j) {
            this.i = i;
            this.j = j;
        }
    }
}



Measured memory_bytes: 35600
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll n,k,x[200],ans;
  ans=0;
  cin >> n >> k;
  rep(i,n)cin >> x[i];
  rep(i,n)ans+=min(x[i],k-x[i]);
  printf("%lld",ans*2);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int sum = 0;
        int[] arr = new int[N];
        for (int i=0; i<N; i++) {
            arr[i] = sc.nextInt();
        }
        for (int i=0; i<N; i++) {
            for (int j=i+1; j<N; j++) {
                sum += arr[i]*arr[j];
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 22612
a=int(input())
b=input()
d=0

for i in range(a):
 c=0
 data=b[0:i]
 match=b[i:a]
 data_uniq=list(set(data))
 match_uniq=list(set(match))
 for x in range(len(data_uniq)):
  for y in range(len(match_uniq)):
   if data_uniq[x]==match_uniq[y]: 
    c+=1
    d=max(d,c)
                   

print (d)

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
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));
}

//a,b x
int main(){
	ll A,B,X; cin>>A>>B>>X;
	cout<<((X>=A && X<=A+B)?"YES":"NO");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};




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

string s,t;
cin>>s>>t;
int a,b; cin>>a>>b;
string u; cin>>u;
if(u==s)a--;
else b--;

cout<<a<<" "<<b;






}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int s, w; cin >> s >> w;
  if(s <= w) cout << "unsafe" << endl;
  else cout << "safe" << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long A = scan.nextLong();
        long B = scan.nextLong();
        long C = scan.nextLong();
        long D = scan.nextLong();
        long gcd = gcd(C, D);
        long lcm = C * D / gcd;
        long countC = B / C - (A - 1) / C;
        long countD = B / D - (A - 1) / D;
        long countLCM = B / lcm - (A-1) / lcm;
        long x = countC + countD - countLCM;
        System.out.println(B-A+1-x);
    }
    public long gcd(long x, long y) {
        if (x > y) {
            long t = x;
            x = y;
            y = t;
        }
        while (x % y != 0) {
            long t = y;
            y = x % y;
            x = t;
        }
        return y;
    }
}


Measured memory_bytes: 23252