akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int w,h,n;
    cin>>w>>h>>n;
    int x1=0,y1=0,x2=w,y2=h;
    
    for(int i=0;i<n;i++){
        int x,y,a;
        cin>>x>>y>>a;
        
        if(a==1) x1=max(x1,x);
        if(a==2) x2=min(x2,x);
        if(a==3) y1=max(y1,y);
        if(a==4) y2=min(y2,y);
    }
    
    int tate=max(0,y2-y1);
    int yoko=max(0,x2-x1);
    
    cout<<tate*yoko<<endl;
    
    return 0;
}

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

int l[200010], r[200010], lqz[200010], rqz[200010], s[200010];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d%d", &l[i], &r[i]);
		lqz[l[i]]++;
		rqz[r[i]]++;
		s[l[i]]++;
		s[r[i]]--;
	}
	for (int i = 1; i <= 100000; ++i)
	{
		lqz[i] += lqz[i - 1];
		rqz[i] += rqz[i - 1];
		s[i] += s[i - 1];
	}
	int ans1(0), ans2(0);
	for (int i = 0; i < n; ++i)
		ans1 = max(ans1, lqz[r[i] - 1] - rqz[l[i]]);
	for (int i = 1; i <= 100000; ++i)
		ans2 = max(ans2, s[i]);
	printf("%d %d\n", ans1, ans2);
	
	return 0;
}


Measured memory_bytes: 5928
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var y = cin.ReadInt;

            for (int i = 0; i <= n; i++)
            {
                for (int j = 0; j <= n-i; j++)
                {
                    if (n - (i + j) >= 0)
                    {
                        var k = n - (i + j);
                        if ((10000 * i + 5000 * j + 1000 * k) == y)
                        {
                            WriteLine($"{i} {j} {k}");
                            return;
                        }
                    }
                }
            }
            WriteLine("-1 -1 -1");
        }
    }

    public static class Extensions
    {
        
    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }

        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }

        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReaddoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}

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

int main() {
  int n;
  long long k;
  cin >> n >> k;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  int now = 1;
  if (k < n) {
    for (int i = 0; i < k; i++) now = a[now];
  } else {
    vector<int> mem(n + 1);
    mem[0] = now;
    for (int i = 0; i < n; i++) mem[i + 1] = a[mem[i]];
    now = mem[n];
    int round;
    for (int i = n - 1; i >= 0; i--) {
      if (now == mem[i]) {
        round = n - i;
        break;
      }
    }
    for (int i = 0; i < (k - n) % round; i++) now = a[now];
  }
  cout << now << endl;
  return 0;
}

Measured memory_bytes: 4764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main {
	
	static class Scanner{
		BufferedReader br=null;
		StringTokenizer tk=null;
		public Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		public String next() throws IOException{
			while(tk==null || !tk.hasMoreTokens()) {
				String cad = br.readLine();
				if (cad == null)
					return null;
				tk=new StringTokenizer(cad);
			}
			return tk.nextToken();
		}
		public int nextInt() throws NumberFormatException, IOException{
			return Integer.valueOf(next());
		}
		public long nextLong() throws NumberFormatException, IOException{
			return Long.valueOf(next());
		}
		public double nextDouble() throws NumberFormatException, IOException{
			return Double.valueOf(next());
		}
	}
	
	
	static char[] s;
	
	static int f() {
		int l = 0;
		int r = s.length - 1;
		int add = 0;
		while(l < r) {
			if (s[l] == s[r]) {
				l++;
				r--;
			}
			else if (s[l] == 'x') {
				add++;
				l++;
			}
			else if (s[r] == 'x') {
				add++;
				r--;
			}
			else
				return -1;
		}
		return add;
	}
	
	public static void main(String args[]) throws IOException {
		Scanner sc = new Scanner();
		s = sc.next().toCharArray();
		System.out.println(f());
	}

}


Measured memory_bytes: 24404
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        String res = in.nextLine();
        in.close();
        boolean isMatch = false;

        loop:
        for (int i = 0; i < str.length(); i++) {
            for (int j = 0; j < str.length(); j++) {
                if (str.charAt(j) != res.charAt((i+j)%str.length())) {
                    break;
                } else if (j == str.length() - 1 && str.charAt(j) == res.charAt( (i+j) % str.length() )) {
                    isMatch = true;
                    break loop;
                }
            }
        }

        String ans = isMatch ? "Yes" : "No";
        System.out.println(ans);
    }

}

Measured memory_bytes: 21332
#include "bits/stdc++.h"
#define ll long long
#define ld long double 
#define For(i, a, n) for(long long i = a; (a < n) ? (i < n) : (i > n); (a < n) ? (i++) : (i--))
#define ee 1000000007
#define pb push_back
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;
  
void solve() {
	ll n; string s;
  cin >> n >> s;
  ll w = 0, r = 0;
  For(i, 0, n) {
    if(s[i] == 'W')
      w++;
    else
      r++;
  }
  if(r == 0 || w == 0)
    cout << 0 << "\n";
  else {
    ll p = 0;
    For(i, r, n) {
      if(s[i] == 'R')
        p++;
    }
    cout <<p << "\n";
  }
}

int main() {
    fio;
    ll t = 1;
    //cin >> t;
    while(t--) {
    	solve();
    }
}


Measured memory_bytes: 3776
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t=sc.nextInt();
		long a[][]=new long[t][4];

		long gcd;
		long test;
		boolean ans;

		for(int i=0; i<t;i++) {
			for(int j=0;j<4;j++) {
				a[i][j]=sc.nextLong();
			}
		}
		for(int i=0;i<t;i++) {
			if(a[i][0]<a[i][1]||a[i][1]>a[i][3]) {
				ans=false;
			}
			else if(mod(a[i][3], a[i][1])==0) {
				test=mod(a[i][0], a[i][1]);
				ans=true;
				if(test>a[i][2]) {
					ans=false;
				}
			}
			else {
				a[i][0]=mod(a[i][0], a[i][1]);
				a[i][3]=mod(a[i][3], a[i][1]);

				ans=true;
				gcd=saidaikouyakusuu(a[i][3], a[i][1]);
				test=mod(a[i][1], gcd)-gcd;
				if(a[i][1]+test>a[i][2]) {
					ans=false;
				}

				/*
				test=0;
				ans=true;
				do{
					test=mod(test+gcd, a[i][1]);
					if(test<a[i][1]&&test>a[i][2]) {
						ans=false;
					}
				} while(test!=0);*/



			}


			if(ans) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}

	}

	public static long mod(long a,long b) {
		return(a%b);
	}

	public static long saidaikouyakusuu(long x, long y) {
		if(x<y) {
			long swap=x;
			x=y;
			y=swap;
		}
		if(y!=0) {
			long tmp;
	        while ((tmp = x % y) != 0) {
	            x = y;
	            y = tmp;
	        }

		}
		return y;
	}

}


Measured memory_bytes: 25316
#include<iostream>
#include<string>
using namespace std;
int main(){
    string a;
    cin>>a;
    int sum=0; 
    for(int i=0;i<a.size();i++){
        if(a[i]=='C'){
            sum=1;
        }
        if(a[i]=='F'&&sum==1){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())
ans = []
if max(A,B) == 1:
	print(1)
	exit()
for i in range(1,max(A,B)+1):
	if A % i == 0 and B % i == 0:
		ans.append(i)
ans.sort(reverse=True)
print(ans[K-1])


Measured memory_bytes: 38384
// g++ -std=c++11 temp.cpp
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PL;
//typedef pair<P, ll> PL;

#define INF INT_MAX/3

#define MAX_N 1000

ll h,w,n;
PL bl[100001];
vector<PL> v;
ll res[10];

int main(){
	cin.sync_with_stdio(false);
	cin>>h>>w>>n;
	rep(i,n){
		cin>>bl[i].first>>bl[i].second;
		bl[i].first--; bl[i].second--;
	}
	//sort(bl,bl+n);
	rep(i,n){
		ll blx=bl[i].second, bly=bl[i].first;
		for(int dx=-2;dx<=0;dx++)for(int dy=-2;dy<=0;dy++){
			ll nx=blx+dx,ny=bly+dy;
			if(nx>=0&&ny>=0&&nx+2<w&&ny+2<h){
				v.pb(PL(ny,nx));
			}
		}
	}
	sort(all(v));
	int prev=0,next=0;
	while(next<v.size()){
		while(next<v.size()&&v[prev]==v[next])next++;
		res[next-prev]++;
		prev=next;
	}
	res[0]=(w-2)*(h-2);
	repl(i,1,10)res[0]-=res[i];
	rep(i,10)cout<<res[i]<<endl;
	return 0;
}





Measured memory_bytes: 18280
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int A, B;
int main(void){
    cin >> A >> B ;
    cout << max(A+B, max(A-B,A*B)) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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() {
	string s;
	cin >> s;
	string t;
	rep(i, s.length()) {
		if(s[i] == 'B' && t.length() != 0) {
			t = t.substr(0,t.length()-1);
			/*string v;
			rep(j,t.length()-1) {
				v += t[j]; 
			}
			t = v;
			*/
		}
		else if(s[i] == '0' || s[i] == '1') t += s[i];
	}
	cout << t << endl;

  return 0;
}


Measured memory_bytes: 256
# coding: utf-8

while True:
    a,op,b = (x for x in input().strip().split())
    a = int(a)
    b = int(b)
    
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    elif op == "?":
        exit()


Measured memory_bytes: 5608
import java.util.Scanner;
public class Main{
	public static void main(String args[]){
    	Scanner sc=new Scanner(System.in);
      	int n=sc.nextInt();
      	int k=sc.nextInt();
      	int arr[]=new int[n];
      	for(int i=0;i<n;i++) arr[i]=sc.nextInt();
      
      	long dp[]=new long[n];
      	dp[0]=0;
      	dp[1]=Math.abs(arr[1]-arr[0]);
      	for(int i=2;i<n;i++){
          	long min=Long.MAX_VALUE;
        	for(int j=i-1;j>=0&&j>=i-k;j--){
            	long temp=dp[j]+Math.abs(arr[i]-arr[j]);
              	if(temp<min) min=temp;
            }
         	dp[i]=min;
        }
      	System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 50660
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

// vector 操作  vector<int> data(10,5) 5が10個　data(10) 要素数10
// v.size(), v.empty(), v.insert(itr,値), v.erase(itr) (first,last),
// sort(itr), find(all(x),値),reverse(itr),accumulate(itr,0) 積算,
//v.swap
// stringも同じ itrがただの数字になる
// s.substr(n,m)n番目以降m文字取り出す　erase(n,m)も  s.find
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

// map 操作  map<string,int> mp キー=string 値=int型  pair< , >型
// 代入:mp["abc"]=123  mp.erase(キー)
// itr = mp.begin()のとき　itr->first = key, itr->second = val
// mp.find(key) itrを返す
typedef pair<int,int> P;  //q(p.first,p.second)で定義できる？

// lcm( , ) gcd( , ) 最大公約数　最小公倍数
//if(cin.eof()) break; 入力数が決まってないとき
//ifstream  whilwee(ifs>>data)

// 浮動小数点
// cout << fixed; 以下と組fみ合わせで小数点以下n桁
// cout << setprecision(n) << 値; n桁表記
// defaultfloat

///////////////// SelectionSort(A,N) ////////////

int SelectionSort(vector<int>& a,int n){
    
    int count=0;
    for(int i=0;i<n;i++){
        int minj = i;
        for(int j=i;j<n;j++){
            if(a[minj]>a[j]){
                minj = j;
            }
        }
        swap(a[minj],a[i]);
        if(minj!=i){
            count++;
        }
    }
    return count;
}


int main (){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }

    int count = SelectionSort(a,n);

    REP(i,n-1){
        cout << a[i] << ' ';
    }
    cout << a[n-1] << endl;
    cout << count << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(){

	int n,m; cin>>n>>m;
	vector<int> g[n];
	memset(g, 0, sizeof g);
	for(int i=0; i<m; i++){
		int x,y; cin>>x>>y;
		g[x-1].push_back(y-1);
		g[y-1].push_back(x-1);
	}
	for(int i=0; i<g[0].size(); i++){
		for(int j=0; j<g[g[0][i]].size(); j++){
			if(g[g[0][i]][j] == n-1){cout<<"POSSIBLE"; return 0;}	
		}
	} 
	cout<<"IMPOSSIBLE"; return 0;
}

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

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

int main(){
	int r, g, b;
	cin >> r >> g >> b;
	if((r*100+10*g+b)%4) cout << "NO" << endl;
	else cout << "YES" << endl;

	return 0;
}

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    ll s = 0;
    for(int i=0; i<n; ++i){
        cin >> a[i];
        s+=a[i];
    }

    if(s%10==0){
        sort(a.begin(), a.end());
        for(int i=0; i<n; ++i){
            if((s-a[i])%10 != 0){
                cout << s-a[i];
                return 0;
            }
        }
        cout << 0;
    }
    else    
        cout << s;
}


Measured memory_bytes: 3580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class ABC043
    {
        static void Main(string[] args) {
            var s = Console.ReadLine();
            string res = "";
            foreach(var c in s) {
                if(c != 'B') {
                    res += c;
                }else if(c == 'B' && res.Length != 0) {
                    res = res.Remove(res.Length - 1);
                }
            }




            Console.WriteLine(res);
        }
}
}

Measured memory_bytes: 2648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
const int INF = 1<<28;
const ll MOD = 1000000007;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

struct s {
	int px, py, cx, cy, cnt;
	s() {};
	s(int a, int b, int c, int d, int e) : px(a), py(b), cx(c), cy(d), cnt(e) {};
};

int w, h;
set<int> memo;
bool done[7][7]; //??¢?´¢?????¢
bool b[7][7]; //?????????????????¨??????
int m[7][7]; //?????????

bool chk(int y, int x) {
	if(x < 0 || y < 0 || h-1 < y || w-1 < x)
		return false;
	return true;
}

void dfs(int y, int x, int cy, int cx) {
	REP(i, 4) {
		int x2 = x + dx[i], y2 = y + dy[i];
		if(chk(y2, x2) && !done[y2][x2]) {
			if(m[y2][x2] == 0 || m[y2][x2] == 3) {
				if(cy == y && cx == x)
					return;
				done[y2][x2] = true;
				b[y2][x2] = true;
				dfs(y2, x2, cy, cx);
			}
		}
	}
	return;
}

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

	while(cin >> w >> h, w|h) {
		queue
 q;
		s a;
		memset(m, false, sizeof(m));
		memo.clear();
		REP(i, h) {
			REP(j, w) {
				cin >> m[i][j];
				if(m[i][j] == 4) {
					a.py = i; a.px = j;
					m[i][j] = 0;
				}
				if(m[i][j] == 2) {
					a.cy = i; a.cx = j;
					m[i][j] = 0;
				}
			}
		}
		q.push(a);

		int ans = -1;
		while(q.size()) {
			s a = q.front(); q.pop();

			memset(done, false, sizeof(done));
			memset(b, false, sizeof(b));
			b[a.py][a.px] = true;
			dfs(a.py, a.px, a.cy, a.cx);

			bool flg = false;
			REP(i, 4) {
				int cx2 = a.cx + dx[i], cy2 = a.cy + dy[i];
				int cx3 = a.cx + dx[(i+2)%4], cy3 = a.cy + dy[(i+2)%4];
				int d = cx2 * 1000 + cy2 * 100 + cx3 * 10 + cy3;
				if(!chk(cy2, cx2) || !chk(cy3, cx3))
					continue;
				if(b[cy2][cx2] && (m[cy3][cx3] == 0 || m[cy3][cx3] == 3) && !memo.count(d)) {
					if(m[cy3][cx3] == 3) {
						ans = a.cnt + 1;
						flg = true;
					}
					q.push(s(a.cx, a.cy, cx3, cy3, a.cnt + 1));
					memo.insert(d);
				}
			}
			if(flg) break;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    copy_n(istream_iterator<int>(cin), n, A.begin());
    nth_element(A.begin(), A.begin() + k, A.end(), greater<int>());

    cout << accumulate(A.begin(), A.begin() + k, 0) << endl;
}

Measured memory_bytes: 256
N,D = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(N)]
count = 0
for i in range(N-1):
  X1 = X[i]
  for j in range(i+1,N):
    X2 = X[j]
    d2 = 0
    for k in range(D):
      d2 += (X1[k]-X2[k])**2
    if d2**0.5 == int(d2**0.5):
      count += 1
print(count)

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

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; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll N;
  cin>>N;
  vector<vector<ll>> ball(N,vector<ll>(2));
  for(ll i = 0LL; i < N; i++) cin>>ball[i][0]>>ball[i][1];
  ll ans = 0LL;
  map<pair<int,int>,int> mp;
  for(ll i = 0LL; i < N; i++) {
    for(ll j = 0LL; j < N; j++) {
      if(i==j)continue;
      ll p = ball[i][0]-ball[j][0];
      ll q = ball[i][1]-ball[j][1];
      mp[make_pair(p,q)]++;
    }
  }
  int m = 0;
  for(auto x:mp){
    chmax(m,x.second);
  }
  cout<<N-m<<endl;
}

Measured memory_bytes: 384
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> s(M), c(M);
  for (int i = 0; i < M; ++i)cin >> s[i] >> c[i];
  vector<int> ans(N, -1);
  for (int i = 0; i < M; ++i) {
    if (ans[s[i] - 1] != -1 && ans[s[i] - 1] != c[i]) {
      cout << -1 << endl;
      return 0;
    }
    ans[s[i] - 1] = c[i];
  }
  if (N > 1 && ans[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < N; ++i) {
    if (ans[i] != -1)continue;
    ans[i] = (N > 1 && i == 0) ? 1 : 0;
  }
  for (const auto elem : ans)cout << elem;
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;char s,t; cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>s;
    if(i+1==k){
      if(s=='A') s='a';
      if(s=='B') s='b';
      if(s=='C') s='c';
    }
    cout<<s;
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

vl a;
vvl G;
vl dp;  // dp[j] : a[i]までで長さj+1のLISの末尾要素の最小値
vl ans;

void dfs(ll v, ll p = -1) {
    // 行きの処理はこのへんに書く
    ll id = lower_bound(all(dp), a[v]) - dp.begin();
    ll x = *lower_bound(all(dp), a[v]);
    *lower_bound(all(dp), a[v]) = a[v];
    ans[v] = lower_bound(all(dp), INF) - dp.begin();
    for(auto u : G[v]) {
        if(u == p) {
            continue;
        }
        dfs(u, v);
        // 帰りの処理はこのへんに書く
    }
    dp[id] = x;
}

int main() {
    ll n;
    cin >> n;

    a.resize(n);
    rep(i, n) {
        cin >> a[i];
    }

    G.resize(n);
    rep(i, n-1) {
        ll u, v;
        cin >> u >> v;
        u--;  v--;
        G[u].pb(v);
        G[v].pb(u);
    }

    dp.assign(n, INF);
    ans.resize(n);
    const ll root = 0;
    dfs(root);
    
    rep(i, n) {
        out(ans[i]);
    }
    
    re0;
}

Measured memory_bytes: 30292
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();
        int turn1 = (int)Math.ceil(c / (double)b);
        int turn2 = (int)Math.ceil(a / (double)d);
        System.out.println(turn1<=turn2 ? "Yes" : "No");
    }
}


Measured memory_bytes: 35744
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
L = inpl()

cnt = 0
for i,j,k in itertools.combinations(L,3):
    if i != j and j != k and k != i and max(i,j,k) < (i+j+k) - max(i,j,k):
        cnt += 1

print(cnt)

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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int diffx = tx-sx, diffy = ty-sy;
  for (int i=0; i<diffy; i++) cout << 'U';
  for (int i=0; i<diffx; i++) cout << 'R';
  for (int i=0; i<diffy; i++) cout << 'D';
  for (int i=0; i<diffx; i++) cout << 'L';
  cout << 'L';
  for (int i=0; i<diffy+1; i++) cout << 'U';
  for (int i=0; i<diffx+1; i++) cout << 'R';
  cout << 'D';
  cout << 'R';
  for (int i=0; i<diffy+1; i++) cout << 'D';
  for (int i=0; i<diffx+1; i++) cout << 'L';
  cout << 'U' << endl;
}

Measured memory_bytes: 256
a = int(input())
l = list(map(int,input().split()))
MOD = 998244353
dp = [0]*a
for i in l:
    dp[i]+=1
res = 1
# print(dp)
if dp[0] != 1 and l[0]!=0:
    print(0)
    exit()

for i in l[1:]:
    # print(i)
    res*=dp[i-1]
    res%=MOD

print(res)


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// ------------------------------------------------

		int n = Integer.parseInt(sc.next());

		long ret = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 15 == 0) {

			} else if (i % 3 == 0) {

			} else if (i % 5 == 0) {

			} else {
				ret += i;
			}
		}
		out.println(ret);

		// ------------------------------------------------
		sc.close();
		out.flush();
	}
}

Measured memory_bytes: 26760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main(){
    string s = "YES";
    int a, b, c;    cin >> a >> b >> c;
    if(b-a!=c-b) s = "NO";

    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	int a = (int)N / 1.08;
	int b = a + 1;
	int n, m;
	n = a * 1.08;
	m = b * 1.08;
	//cout << n << ' ' << m << endl;

	if (n == N) cout << a << endl;
	else if (m == N) cout << b << endl;
	else cout << ":(" << endl;
}

Measured memory_bytes: 3636
import itertools 
N,K =list(map(int,input().split()))
p =list(map(int,input().split()))
E = [0] * N

for i in range(N):
  E[i]=(p[i]+1)/2
acc = [0]
acc += list(itertools.accumulate(E))

ans = 0
for i in range(N-K+1):
  ans = max(acc[i+K] - acc[i], ans)

print(ans)

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

int main() {
  string N;
  cin>>N;
  if(N.at(0)=='7'||N.at(1)=='7'||N.at(2)=='7'){
cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  
  
}


Measured memory_bytes: 3624
# include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007



int main()
{
    int A, B, T;
    cin >> A >> B >> T;
    ce(T/A*B)

}

Measured memory_bytes: 384
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Scanner;

/**
 * TITLE : Poll URL : https://atcoder.jp/contests/abc155/tasks/abc155_c
 */
public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String, Integer> map = new HashMap();
        for (int i = 0; i < N; i++) {
            String S = sc.next();
            if (!map.containsKey(S)) {
                map.put(S, 1);
            }
            else {
                map.put(S, map.get(S).intValue() + 1);
            }
        }
        // map.entrySet().stream().forEach(System.out::println);
        Optional<Entry<String, Integer>> maxEntry = map.entrySet().stream()
                .max(Comparator.comparing(Map.Entry::getValue));
        map.entrySet().stream().filter(x -> maxEntry.get().getValue() == x.getValue()).sorted(
                Map.Entry.<String, Integer> comparingByValue().reversed().thenComparing(Map.Entry.comparingByKey()))
                .forEach(x -> System.out.println(x.getKey()));
        sc.close();
    }
}

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

#ifdef INPUT
#include <sstream>
stringstream input_(R"(
1 100 2 10
)");
#define cin input_
#endif

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (abs(c-a)<=d) 
		cout << "Yes" << endl;
	else if (abs(c-b)<=d && abs(b-a)<=d)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    int64_t h[302];
    h[0] = 0;
    h[N+1] = 0;
    for(int i=1;i<=N;++i) cin >> h[i];
    static int64_t dp[301][301][301];
    static int64_t memo[302][301];
    for(int i=0;i<=N;++i){
        for(int j=0;j<=K;++j){
            for(int k=0;k<=N;++k) dp[i][j][k] = 1e15;
            memo[i][j] = 1e15;
        }
    }
    dp[0][0][0] = 0;
    memo[1][0] = h[1];
    for(int i=1;i<=N;++i){
        dp[i][0][i] = dp[i-1][0][i-1] + max(INT64_C(0), h[i]-h[i-1]);
        for(int j=1;j<=i;++j){
            for(int k=0;k<i;++k){
                dp[i][j][k] = dp[i-1][j-1][k];
                memo[i+1][j] = min(memo[i+1][j], dp[i][j][k] + max(INT64_C(0), h[i+1]-h[k]));
            }
            dp[i][j][i] = memo[i][j];
            memo[i+1][j] = min(memo[i+1][j], dp[i][j][i] + max(INT64_C(0), h[i+1]-h[i]));
        }
    }
    
    int64_t ans = 1e15;
    for(int i=0;i<=N;++i) ans = min(ans, dp[N][K][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 214016
a = int(input()) 
b = int(input())
c = int(input())
d = int(input())

total = 0
if a == b:
    total+=a
elif a < b:
    total+=a
else:
    total+=b

if c == d:
    total+=c
elif c < d:
    total+=c
else:
    total+=d

print(total)

Measured memory_bytes: 3316
#include <stdio.h>
int main()
{
    int H, A, rem, div;
    scanf("%d %d", &H, &A);
    div = H/A;
    rem = H%A;

    if(rem > 0){
        div += 1;
        printf("%d", div);
    }
    if(rem == 0){
        printf("%d", div);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

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

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

    string s;
    cin >> s;
    map<char, int> m;
    for(auto it : s)
        m[it] ++;
    bool flag = 1;
    for(auto it : s)
        if(m[it] != 2)
            flag = 0;
    if(flag)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)

int main() {
	int N, s[102], ans = 0;
	cin >> N;
	REP(i, N) {
		cin >> s[i];
	}

	sort(s, s + N);

	REP(i, N) {
		ans += s[i];
	}

	if (ans % 10 == 0) {
		REP(i, N) {
			if (s[i] % 10 != 0) {
				ans -= s[i];
				break;
			}
			if (i == N - 1) {
				cout << 0 << endl;
				return 0;
			}
		}
	}

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

Measured memory_bytes: 256
print=console.log;
ls=require("fs").readFileSync("/dev/stdin","utf-8").split("\n");ls.length--
Array.prototype.trace = function(){ print(this); return this };
Object.prototype.trace = function(){ print(this+""); return this };
String.prototype.int = function(c){ return this.split(c||" ").map(int)};
Array.prototype.max = function(){ return Math.max.apply(null, this) };
Array.prototype.min = function(){ return Math.min.apply(null, this) };
Array.prototype.copy = function(){ return this.map(id) };
Array.prototype.rotate = function(n){
  return this.slice(n, this.length).concat(this.slice(0, n));
};
Array.prototype.permutation = function () {
  if (this.length == 0) return [];
  if (this.length == 1) return [this];
  var ret=[], ar=this, i=0;
  for (; i<ar.length; ++i)
    ret=ret.concat(ar.slice(0, i)
           .concat(ar.slice(i+1, ar.length))
           .permutation()
           .map(function(p){ return p.concat(ar[i]) }));
  return ret;
};
Array.prototype.flatten = function() {
  for (var i=0, ret=[]; i<this.length; ++i) ret=ret.concat(this[i]);
  return ret;
};
function iota(n, b, s) {
  b=b||0; s=s||1; for (var ret=[]; n--; b+=s) ret.push(b); return ret;
}
function int(s){return +s}
function add(a,b){return a+b}
function sub(a,b){return a-b}
function bus(a,b){return b-a}
function id(x){return x}

(function main() {
  var l = ls[0];
  print(l[0] == l[l.length-1] ? l[0] : "o");
})();

// vim: set ft=javascript:

Measured memory_bytes: 7652
#include <bits/stdc++.h>
#define fo(i, n) for(int i = 0; i < n; ++i)
#define ll long long int
#define fok(i, k, n) for(int i = k; i < n; ++i)
#define MOD 1000000000+7
#define all(X) X.begin(), X.end()
#define pb push_back
#define present(a, x) (a.find(x)!=a.end())
using namespace std;

map <int, set <int> > m;

int main(){
  map <int,int> m;
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n-1;i++){
    cin>>a[i];
    m[a[i]]++;
  }
  for(int i=1;i<=n;i++){
    cout<<m[i]<<"\n";
  }
   // cerr << "Execution time: " << (etime - stime) / CLOCKS_PER_SEC * 1000 << " ms.\n";
}

Measured memory_bytes: 13752
import numpy as np

K,N = map(int, input().split())
An_list = np.array(input().split(), dtype=int)

An_delta_list = np.diff(An_list)
An_delta_list = np.append(An_delta_list, (K - An_list[-1])+An_list[0])
An_delta_max = np.max(An_delta_list)
result = np.sum(An_delta_list) - An_delta_max
print(result)

Measured memory_bytes: 41296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

template <typename T> T gcd(T x, T y) { return( y ? gcd(y, x % y) : x); }
template <typename T> T lcm(T x, T y) { return( x / gcd(x, y) * y); }
template <typename T> void printVec(vector<T> &vec) {
  cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    cout << *it << " ";
  }
  cout << endl;
}

int main() {
  int x, n;
  cin >> x >> n;
  vector <int> p(n);

  for(int i = 0; i < n; i++) {
    cin >> p[i];
  }
  int v = INT_MAX;
  int ans = -1;
  sort(p.begin(), p.end());
  int point = 0;
  int d;
  for(int i = -200; i <= 200; i++) {
    if (point < n) {
      if (i != p[point]) {
        // cout << "i = " << i << endl;
        d = abs(i - x);
        if (d < v) {
          v = d;
          ans = i;
        }
      } else {
        point = point + 1;
      }
    } else {
      d = abs(i - x);
      if (d < v) {
        v = d;
        ans = i;
      }     
    }
  }
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 998244353
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    vector<ll> dp(n+1, 0);
    vector<ll> sum(n+1, 0);
    dp[0] = 1;
    sum[1] = 1;
    vector<pair<int,int>> segment(k);
    rep(i,0,k){
      cin >> segment[i].first >> segment[i].second;
    }

    rep(i,1,n){
        rep(j,0,k){
            int left = max(0, i - segment[j].second);
            int right = i - segment[j].first + 1;
            if(right < 1) continue;

            dp[i] += ((sum[right] - sum[left]) % MOD + MOD) % MOD;
        }
        sum[i+1] += (sum[i] + dp[i]) % MOD;
    }

    cout << dp[n-1] % MOD << endl;
    return 0;
}

Measured memory_bytes: 6308
# coding: utf-8
n = int (input())
s=list(input())

w_count = 0
r_count = 0

for item in s:
    if (item == "W"):
        w_count+=1
    elif (item == "R"):
        r_count+=1

target = ["R"] * r_count + ["W"] * w_count

ans_count = 0
for i in range(n):
    if (s[i] != target[i]):
        ans_count+=1
print (int(ans_count / 2))

Measured memory_bytes: 13612
#include <bits/stdc++.h>
using namespace std;
string a;
int main() {
    cin >> a;
    int len = a.length();
    bool flag = false;
    for (int i = 0; i < len; ++ i) {
        if (!flag) {
            if (a[i] == 'C') flag = true;
        }
        if (flag) {
            if (a[i] == 'F') return printf("Yes\n"), 0;
        }
    }
    printf("No\n");
}

Measured memory_bytes: 256
import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys

sys.setrecursionlimit(10 ** 5 + 10)


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


def resolve():
    def main():
        a, b, x = map(int, input().split())
        x = x / a
        # failed/clearの境界がある場合のスコアの（最大）最小値を求める場合、
        # failedかclearで二分探索をする。

        # https://atcoder.jp/contests/abc146/tasks/abc146_c

        # 探索範囲を適当に定める
        l = 0
        r = math.pi/2

        # 以降、r以降はfailedという設定。それゆえ、初期rでclearの場合は例外。
        while l + 10 ** (-10) < r:
            estimate = (l + r) / 2
            if b*math.tan(math.pi / 2 - estimate) <= a:
                #print(b * b * math.tan(math.pi / 2 - estimate)*0.5)
                if b * b * math.tan(math.pi / 2 - estimate)*0.5 >= x:
                    l = estimate
                else:
                    r = estimate
            else:
                if a * b - (a * a * math.tan(estimate)*0.5) >= x:
                    #print(a * b - (a * a * math.tan(estimate)*0.5))
                    l = estimate
                else:
                    r = estimate

        return math.degrees(l)  # それゆえlを返す

    print(main())


resolve()

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	int n, d;
	cin >> n >> d;
	if (n % (d * 2 + 1) == 0) {
		cout << n / (d * 2 + 1) << endl;
	}
	else {
		cout << n / (d * 2 + 1) + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  int n,d;
  cin >> n >> d;
  vii data(n,vi(d));
  rep(i,n) rep(j,d) cin >> data[i][j];
  int ans = 0;
  dset(10);
  rep(i,n) {
    rep(j,n) {
      if(i < j) {
        ind dist = 0;
        rep(k,d) dist += (data[i][k]-data[j][k])*(data[i][k]-data[j][k]);
        dist = sqrt(dist);
        if(dist == (int)dist) ans++;
      }
    }
  }
  cout << ans;
  hinata;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int a, b;
    cin >> a >> b;
    cout << ((a * b) % 2 ? "Odd" : "Even") << endl;
    
    return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> p(N);
	for(int i=0;i<N;i++)cin >> p[i];
	
	int count=0;
	for(int i=0;i<N;i++){
		if(p[i]!=i+1)count++;
	}
	if(count<=2)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    long p = 1000000007;
    int N = Integer.parseInt(sc.nextLine());
    String[] S = sc.nextLine().split(" ");
    int r = 0, g = 0, b = 0;
    long ans = 1;
    for(int i = 0; i < N; i++){
      int M = Integer.parseInt(S[i]);
      int count = 0;
      if(r == M) count++;
      if(g == M) count++;
      if(b == M) count++;
      
      ans *= count;
      ans %= p;
      
      if(r == M){
        r++;
      }else if(g == M){
        g++;
      }else if(b == M){
        b++;
      }
    }
    System.out.println(ans);
  }
}


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

int main(void) {
    int N,K,ans;
    cin >> N >> K;

    vector<int> A(N);
    for(int i=0;i<N;i++) {
        cin >> A[i];
    }
    
    if(N%(K-1)) {
        if(N%(K-1) == 1) {
            ans = N/(K-1);   
        } else {
            ans = N/(K-1) + 1;   
        }
    } else {
        if(K == 2) {
            ans = N-1;
        } else {
            ans = N/(K-1);
        }
    }

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


Measured memory_bytes: 640
import java.util.Scanner;
class Main {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  while(true) {
   int H = sc.nextInt();
   int W = sc.nextInt();
   if( H == 0 && W == 0 )break;
   for(int i = 1; i <= H; i++ ){
    for( int j = 1; j <= W; j++ ){
     if((i + j)%2 == 0){
      System.out.printf("#");
     }else{
      System.out.printf(".");
     }
    }
    System.out.println();
   }
System.out.println();
  }
 }
}


Measured memory_bytes: 59824