akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=5e3+5,M=5e3+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
int h[N],st[N],a[N][N],b[N][N],H,W,ans;
char s[N];
int main(){read(H,W);ans=max(H,W);
	rep(i,1,H){
		scanf("%s",s+1);
		rep(j,1,W)a[i][j]=s[j]=='#';
	}
	re(i,1,H)re(j,1,W)b[i][j]=!(a[i][j]^a[i+1][j]^a[i][j+1]^a[i+1][j+1]);
	re(i,1,H){
		re(j,1,W)if(b[i][j])h[j]++;else h[j]=0;
		int top=0;
		rep(j,1,W){
			while(top&&h[st[top]]>=h[j]){
				gmax(ans,(h[st[top]]+1)*(j-st[top-1]));
				top--;
			}st[++top]=j;
		}
	}cout<<ans<<endl;
}

Measured memory_bytes: 81408
#include <iostream>

using namespace std;

int main()
{
    string x,y;
    cin>>x>>y;
    int z=y.length();
    int cnt=0;

    for(int i=0;i<z;i++)
    {
        if(x[i]!=y[i])
        {
            cnt++;
        }
    }

    cout<<cnt;
}


Measured memory_bytes: 3820
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include<iomanip>

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

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

typedef long long ll;

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int n;
  int m;
  cin>>n;
  map<string,int> ma;
  rep(i,n){string s;cin>>s;ma[s]++;}
  cin>>m;
  rep(i,m){string t;cin>>t;ma[t]--;}
  int res=0;
  for(auto i:ma)
  {
    chmax(res,i.second);
  }
  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int dummy, count[4] = {0,0,0,0};
    char blood[4];
    while( scanf("%d,%s", &dummy, blood) != EOF ){
        if( blood[0] == 'B' ) count[1]++;
        else if( blood[0] == 'O' ) count[3]++;
        else if( blood[1] == '\0' ) count[0]++;
        else count[2]++;
    }
    printf("%d\n%d\n%d\n%d\n", count[0], count[1], count[2], count[3]);
    return 0;
}

Measured memory_bytes: 592
module AOJ_Volume0026;

import std.stdio,std.string,std.conv,std.algorithm;

int f[10][10];

bool checkf(int x,int y)
{
	if(0 <= x && x < 10 && 0 <= y && y < 10)
	{
		return true;
	}
	else
	{
		return false;
	}
}

void dropInk(int x,int y,int size)
{
	if(size == 1)
	{
		f[x][y]++;
		if(checkf(x+1,y)) f[x+1][y]++;
		if(checkf(x-1,y)) f[x-1][y]++;
		if(checkf(x,y+1)) f[x][y+1]++;
		if(checkf(x,y-1)) f[x][y-1]++;
	}
	else if(size == 2)
	{
		foreach(i;-1..2)
		{
			foreach(j;-1..2)
			{
				if(checkf(x+i,y+j)) f[x+i][y+j]++;
			}
		}
	}
	else if(size == 3)
	{
		foreach(i;-1..2)
		{
			foreach(j;-1..2)
			{
				if(checkf(x+i,y+j)) f[x+i][y+j]++;
			}
		}
		if(checkf(x+2,y)) f[x+2][y]++;
		if(checkf(x-2,y)) f[x-2][y]++;
		if(checkf(x,y+2)) f[x][y+2]++;
		if(checkf(x,y-2)) f[x][y-2]++;
	}
}

int main()
{
	foreach(i;0..10)
	{
		foreach(j;0..10)
		{
			f[i][j] = 0;
		}
	}
	string s;
	while((s = readln.chomp).length != 0)
	{
		string[] _s = s.split(",");
		int x = _s[0].to!int;
		int y = _s[1].to!int;
		int size = _s[2].to!int;
		
		dropInk(y,x,size);
	}
	
	int count = 0;
	int ans = 0;
	foreach(i;0..10)
	{
		foreach(j;0..10)
		{
			if(f[i][j] == 0)
			{
				count++;
			}
			ans = max(ans,f[i][j]);
		}
	}
	
	writeln(count);
	writeln(ans);
	return 0;
}

Measured memory_bytes: 1076
s = input()
t = input()
S = len(s)
T = len(t)
dp = [[0]*(T+1) for _ in range(S+1)]

for i in range(S):
    for j in range(T):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

ans = ""
while S and T:
    if dp[S][T] == dp[S-1][T]:
        S -= 1
    elif dp[S][T] == dp[S][T-1]:
        T -= 1
    else:
        ans = s[S-1]+ans
        S -= 1
        T -= 1
print(ans)


Measured memory_bytes: 112220
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


N, M = map(int, input().split())
S = input()
T = input()
gcd = gcd(N, M)

sl = [i for i in range(0, N, N//gcd)]
tl = [i for i in range(0, M, M//gcd)]
for i in range(len(sl)):
    if S[sl[i]] != T[tl[i]]:
        print(-1)
        break
else:
    print(N*M//gcd)


Measured memory_bytes: 5108
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		int[] a = new int[n];
		int ans = 0, sum = 0;

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum += (d - 1)/a[i] + 1;
		}
		
		ans = x + sum;
		

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 23252
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

/*int main(){
    int N;
    cin >> N;
    string s[N];
    int p[N],ind[N];
    for(int i=0;i<N;i++){
      cin >> s[i] >> p[i];
      ind[i] = i + 1;
    }

    for(int i=0;i<N;i++){
      for(int j=0;j<N-1;j++){
        if(s[j] == s[j+1]){
          if(p[j] < p[j + 1]){
            string tmp;
            int t;
            tmp = s[j];
            s[j] = s[j+1];
            s[j+1] = tmp;
            t = p[j];
            p[j] = p[j + 1];
            p[j + 1] = t;
            t = ind[j];
            ind[j] = ind[j + 1];
            ind[j+1] = t;
          }
        }
        else if(s[j] > s[j+1]){
          string tmp;
          int t;
          tmp = s[j];
          s[j] = s[j+1];
          s[j+1] = tmp;
          t = p[j];
          p[j] = p[j + 1];
          p[j + 1] = t;
          t = ind[j];
          ind[j] = ind[j + 1];
          ind[j+1] = t;
        }
      }
    }

    for(int i=0;i<N;i++){
      cout << ind[i] << endl;
    }
    return 0;
}*/

struct shop{
  string s;
  int p;
  int ind;

  bool operator<(const shop& right) const {
    bool x;
    if(s == right.s) x = (p > right.p);
    else x = (s < right.s);
    return x;
  }
};

int main(){
  int N;
  cin >> N;
  shop S[N];
  for(int i=0;i<N;i++){
    string s;
    int p;
    cin >> s >> p;
    S[i] = shop{s, p, i + 1};
  }
  sort(S, S + N);
  for(int i=0;i<N;i++){
    cout << S[i].ind << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Point
{
public:
    double x, y;
    double length(const Point& p) const{
        return sqrt(pow(x - p.x, 2.0) + pow(y - p.y, 2.0));
    }
};

int main()
{
    double s = 0;
    Point p1, p2;
    char c;
    cin >> p1.x >> c >> p1.y >> p2.x >> c >> p2.y;

    for(;;){
        Point p3;
        if(!(cin >> p3.x >> c >> p3.y))
            break;
        double a = p1.length(p2);
        double b = p2.length(p3);
        double c = p3.length(p1);
        double z = (a + b + c) / 2;
        s += sqrt(z * (z-a) * (z-b) * (z-c));

        p2 = p3;
    }

    printf("%.10f\n", s);
}

Measured memory_bytes: 0
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;

fn exec() {
    let mut sc = Scanner::new();
    let n: usize = sc.ne();
    let t: i64 = sc.ne();
    let a: Vec<i64> = (0..n).map(|_| sc.ne()).collect();
    let mut sum = 0;
    for i in 1..n {
        let sa = a[i] - a[i - 1];
        sum += std::cmp::min(t, sa);
    }
    println!("{}", sum + t)
}

fn main() {
    const STACK: usize = 16 * 1024 * 1024;
    let _ = std::thread::Builder::new()
        .stack_size(STACK)
        .spawn(|| { exec(); })
        .unwrap()
        .join()
        .unwrap();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r])
                  .ok()
                  .unwrap()
                  .parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => {
                panic!("parse error, {:?}",
                       String::from_utf8(self.buf[l..r].to_owned()))
            }
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


Measured memory_bytes: 14588
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
long long m, d, x;
int n;
int main() {
    DAU
    cin >> n >> m >> d;
    int l = __builtin_ffsll(d);
    for (int i = 2; i <= n; ++i) {
        cin >> x;
        if (__builtin_ffsll(x) != l || d / 2 > m) {
            d = 2 * m + 2;
            break;
        }
        d *= (x / __gcd(d, x));
    }
    if (d / 2 > m)
        cout << 0;
    else cout << (m - d / 2) / d + 1;
    PLEC
}


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

int main()
{
	string a, b, res = "No";
	cin >> a >> b;
	
 	string ab = a.append(b); 
 
    for(int i = 1; i <= 1000; ++i)
    {
    	if(i * i == stoi(ab))
    	{
    		res = "Yes";
    	}
    }
    
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 3632
N = gets.to_i

def send_query(i)
  puts i
  STDOUT.flush
  res = gets.chomp

  if res == 'Vacant'
    exit
  end

  res
end

type = send_query(0)

ok = 0
ng = N

19.times do |i|
  mid = (ok + ng) / 2
  res = send_query(mid)

  if mid.even?
    if type == res
      ok = mid
    else
      ng = mid
    end
  else
    if type != res
      ok = mid
    else
      ng = mid
    end
  end
end


Measured memory_bytes: 2384
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a = 0;
    if (n % 10 == 9) {
        a += 1;
    } else {
        a += 9;
    }   
    if ((n / 10) % 10 == 9) {
        a += 10; 
    } else {
        a += 90; 
    }   
    if ((n / 100) % 100 == 9) {
        a += 100;
    } else {
        a += 900;
    }   
    cout << a << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define min(a,b) (a>b?b:a)
char S[305];
int cnt[255],i,j;

int main()
{
	gets(S);
	for(i=0;S[i];i++)cnt[S[i]-'A']++;
	printf("%d\n",min(cnt['K'-'A'],min(cnt['U'-'A'],min(cnt['P'-'A'],cnt['C'-'A']))));
	return 0;
}

Measured memory_bytes: 524
import java.util.Scanner;

public class Main{
	
	

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

	int A=sc.nextInt();
	int B=sc.nextInt();
	int price=0;
	if(A<=5) {
		price=0;
	}else if(A>=6&&A<=12) {
		price=B/2;
	}else if(A>=13) {
		price=B;
	}
	
	System.out.println(price);
	
	
	
    

		
	}
	

	
}
		

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){
    int n,d,a;
    cin>>n>>d>>a;
    vector<pair<int,int> > p(n);
    for(int i=0;i<n;i++){
    	cin>>p[i].first>>p[i].second;
    }
    sort(p.begin(),p.end());
    vector<int> s(n+1);
	int r=0;
    long long ans=0;
    rep(i,n){
        p[i].second-=s[i];
        while(r<n&&p[r].first<=p[i].first+2*d)++r;
        if(p[i].second>0){
            int num=(p[i].second+a-1)/a;
            ans+=num;
            s[i]+=num*a;
            s[r]-=num*a;
        }
        s[i+1]+=s[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		String x = "";
		
		try {
			int lim = Integer.parseInt(in.readLine());
			
			int ans = 0;
			for (int i = 0; i < lim; i++) {
				x = in.readLine();
				int num = Integer.parseInt(x);

				boolean flag = true;
				for (int j = 2; (j * j) <= num; j++) {
					if (num % j == 0) {
						flag = false;
						break;
					}
				}
				if (flag) ans++;
			}
			System.out.println(ans);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 28260
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main()
{
  int d;
  cin >> d;
  rep(i, d) cout << 1 << "\n";
  return 0;
}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(exp, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e5+1;
int N;


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    string S;
    cin >> S;
    bool a = true, b = true;
    for(int i=0; i<S.length(); i++)
    {
        if(i%2 == 0 && S[i] == 'L')
        {
            a = false;
        }
        if(i%2 == 1 && S[i] == 'R')
        {
            b = false;
        }
    }

    (a && b) ? cout << "Yes" : cout << "No";
    return 0;
}


Measured memory_bytes: 256
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e17
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll n,h[100001];
ll dp[100001];
ll solve(ll i)
{
	if(i==n-1)
	{
		return 0;
	}
	if(dp[i]!=-1) return dp[i];
	ll ans1=inf,ans2=inf;
	if(i+2<n)ans1 = abs(h[i]-h[i+2])+solve(i+2);
	if(i+1<n)ans2 = abs(h[i+1]-h[i])+solve(i+1);
	return dp[i]=min(ans1,ans2);
}
int main()
{
	boost
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(ll i=0;i<n;i++) cin>>h[i];
	cout<<solve(0)<<endl;
	return 0;
}

Measured memory_bytes: 3328
// https://atcoder.jp/contests/arc062/tasks/arc062_a
#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()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, a1 = 1, a2 = 1;
    cin >> n;
    REP(i, n) {
        ll b1, b2;
        cin >> b1 >> b2;
        long double m1 = (long double)a1 / b1;
        long double m2 = (long double)a2 / b2;
        if (m1 < 1 && m2 < 1) {
            a1 = b1;
            a2 = b2;
        } else {
            if (m1 > m2) {
                a1 = b1 * ceil(m1);
                a2 = b2 * ceil(m1);
            } else {
                a1 = b1 * ceil(m2);
                a2 = b2 * ceil(m2);
            }
        }
    }
    cout << a1 + a2 << endl;

    return 0;
}


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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

template<class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline void init(vector<T>& v) {
	for(T &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(pair<T,U> &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(vector<T>& v, N n) {
	v.resize(n);
	for(T &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(pair<T,U> &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(vector<T>& v, N n, T m) {
	v.resize(n);
	for(T &a: v) { cin>>a; a+=m; }
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n, T t, U u) {
	v.resize(n);
	for(pair<T,U> &a: v) { cin>>a.first>>a.second; a.first+=t; a.second+=u; }
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int N,ans;
intvec A,B,C;

void input() {
	cin>>N;
	init(A,N,-1);
	init(B,N);
	init(C,N-1);
}

void solve() {
	ans=B[A[0]];
	for(int i=1; i<N; i++) {
		ans+=B[A[i]];
		if(A[i]==A[i-1]+1) ans+=C[A[i-1]];
	}
	cout<<ans<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e5 + 5;
const ll LINF = 1e18 + 5;
const int mod = 1e9 + 7;
ll dp[N][13];
char s[N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> (s+1);
 	int n = strlen(s+1);
 	dp[0][0] = 1;
 	for(int i=1; i<=n; i++)
 	{
 		if(s[i]=='?')
 			for(int k=0; k<=12; k++)
 				for(int j=0; j<=9; j++)
 					(dp[i][(k*10+j)%13] += dp[i-1][k]) %= mod;
 		else
 			for(int k=0; k<=12; k++)
 				(dp[i][(k*10+s[i]-'0')%13] += dp[i-1][k]) %= mod;
 	}
 	ll ans = dp[n][5];
 	ans = (ans + mod)%mod;
 	cout << ans;
	return 0;
}


Measured memory_bytes: 10496
#include<iostream>
using namespace std;
long long int n,m,nd;
int main(){
    cin>>n>>m;
    nd=2*n;
    if(nd>m)cout<<m/2<<endl;
    else if(nd==m)cout<<n<<endl;
    else
    {
        m-=nd;
        m/=4;
        cout<<n+m<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long 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;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

const int MAXM=10000;
int A[MAXM];
int main(){
    int N,M;cin >> N >> M;
    int ma= 0;
    rep(i,M){
        cin >> A[i];
        ma += A[i];
    }
    int ans = max(N-ma, -1);
    cout <<  ans << endl;

    return 0;
}

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

int main()
{
    int t,i,cont=0;
    cin>>t;
    bool ara[t] = {0};
    for(i=0;i<t;i++)
    {
        int a,b;
        cin>>a>>b;
        if(a==b)ara[i]=1;
    }
    for(i=0;i<t;i++)
    {
        if(ara[i]==1)cont++;
        else cont = 0;
        if(cont==3)break;
    }
    if(cont == 3)cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
const int MAXN = 55;
ll binom[MAXN][MAXN], pre[MAXN][MAXN];
int main() {
	for (int i = 0; i < MAXN; ++i) {
		for (int j = 0; j <= i; ++j)
			if (!j || j == i) binom[i][j] = 1;
			else binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];
		pre[i][1] = binom[i][1];
		for (int j = 2; j < MAXN; ++j) pre[i][j] = pre[i][j - 1] + binom[i][j];
	}
	int n, k, S, T;
	scanf("%d%d%d%d", &n, &k, &S, &T);
	vector<int> A(n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &A[i]);
	}
	if ((T & S) != S) {
		printf("0\n");
		return 0;
	}
	vector<int> bits;
	for (int j = 0; j < 18; ++j) {
		if ((T & (1 << j)) && !(S & (1 << j))) bits.push_back(j);
	}
	int s = bits.size();
	vector<int> B;
	for (int i = 0; i < n; ++i) {
		if (~T & A[i]) continue;
		if ((S & A[i]) != S) continue;
		int b = 0;
		for (int j = 0; j < s; ++j) {
			if (A[i] & (1 << bits[j])) b |= 1 << j;
		}
		B.push_back(b);
	}
	int req = (1 << s);
	int m = B.size();
	ll ans = 0;
	for (int i = 0; i < m; ++i) {
		vector<int> V;
		for (int j = i + 1; j < m; ++j) {
			int d = B[j] ^ B[i];
			V.push_back(d);
		}
		// 0..K-1 things ORing to req-1.
		for (int b = 0; b < req; ++b) {
			int cnt = 0;
			for (int x : V) {
				if (x & b) continue;
				++cnt;
			}
			ll t = pre[cnt][k - 1] + 1;
			if (__builtin_popcount(b) & 1) ans -= t;
			else ans += t;
		}
	}
	printf("%lld\n", ans);
}


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

int N,A,B,C;
vector<int> L;

int ans(int i, int a, int b, int c)
{
    if(i == N)
    {
        if(a == 0 || b == 0 || c == 0) return 3000;
        return abs(a - A) + abs(b - B) + abs(c - C); 
    }

    int aa = ans(i + 1, a + L[i], b, c) + (0 < a ? 10 : 0);
    int bb = ans(i + 1, a, b + L[i], c) + (0 < b ? 10 : 0);
    int cc = ans(i + 1, a, b, c + L[i]) + (0 < c ? 10 : 0);
    int nn = ans(i + 1, a, b, c);

    return min(aa, min(bb, min(cc, nn)));
}

int main()
{
    cin >> N >> A >> B >> C;
    L.resize(N);

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

    cout << ans(0, 0, 0, 0) << endl; 
    return 0;
}

Measured memory_bytes: 256
def gcd(p, q):
    if (p%q == 0):
        return q
    return gcd(q, p%q)
K = int(input())
result = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            result += gcd(gcd(i, j), k)
print(result)

Measured memory_bytes: 80220
N=int(input())
rates=[0]*8
topcoder=0

for a_ in input().split():
    a=int(a_)
    if 1<=a<=399:
        rates[0]=1
    elif 400<=a<=799:
        rates[1]=1
    elif 800<=a<=1199:
        rates[2]=1
    elif 1200<=a<=1599:
        rates[3]=1
    elif 1600<=a<=1999:
        rates[4]=1
    elif 2000<=a<=2399:
        rates[5]=1
    elif 2400<=a<=2799:
        rates[6]=1
    elif 2800<=a<=3199:
        rates[7]=1
    else:
        topcoder+=1

rate_n=rates.count(1)
print(max(1,rate_n), rate_n+topcoder)


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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int n, k;
  cin >> n >> k;
  vt<int> v(n);
  rep(i, 0, n) cin >> v[i];

  i64 ans = 0;
  rep(i, 1, k + 1) {
    rep(j, 0, i) {
      rep(l, 0, min(n, i - j + 1)) {
        priority_queue<int, vt<int>, greater<int>> que;
        int cnt = min(n, i - j);
        rep(a, 0, l) {
          que.push(v[a]);
          cnt--;
        }
        for(int a = n - 1; cnt > 0; --a, --cnt) que.push(v[a]);

        int a = j;
        while(!que.empty() && a) {
          que.pop();
          --a;
        }

        i64 res = 0;
        while(!que.empty()) {
          res += que.top();
          que.pop();
        }
        ans = max(ans, res);
      }
    }
  }
  cout << ans << endl;
}

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

 
int main() {
    int N;
    cin >> N;
    int C[N-1];
    int F[N-1];
    int S[N][N-1];
    for(int i=0;i<N-1;i++){
        cin >> C[i] >> S[i][i] >> F[i];
    }
    for(int i=0;i<N-1;i++){
        for(int j=0;j<=i;j++){
            if(S[i][j] < S[i][i]){
                S[i+1][j] = S[i][i] + C[i];
            }else{
                S[i+1][j] = S[i][i] + ceil((double)(S[i][j] - S[i][i]) / F[i]) * F[i] + C[i];
            }
        }
    }
    for(int i=0;i<N-1;i++){
        cout << S[N-1][i] << endl;
    }
    cout << 0 << endl;

	return 0;
} 

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  char color;
  for(int i = 0; i < N; i++){
    cin >> color;
    if(color == 'Y'){
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,m,k;
    cin>>n>>m>>k;
    rep(i,n+1){
        rep(j,m+1){
            if(i*(m-j)+j*(n-i)==k){
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
}

Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
const int N = 1000006;
const int Inf = 2e9+7;
//const int alpha = 29;
//const int MOD = 9e8+11339+9*147*3*2;

int n, m;

bool w[101][101];
int dp[101][101];

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			char c;
			cin >> c;
			w[i][j] = c == '#';
		}
	}
	for (int i = 0; i <= n; ++i)
	{
		dp[i][0] = Inf;
	}
	for (int i = 0; i <= m; ++i)
	{
		dp[0][i] = Inf;
	}
	dp[1][1] = w[1][1];
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			if (j == 1 && i == 1)
				continue;
			if (dp[i - 1][j] < dp[i][j - 1])
			{
				dp[i][j] = dp[i - 1][j];
				if (w[i][j] && !w[i - 1][j])
				{
					++dp[i][j];
				}
			}
			else if (dp[i][j - 1] < dp[i - 1][j])
			{
				dp[i][j] = dp[i][j - 1];
				if (w[i][j] && !w[i][j - 1])
				{
					++dp[i][j];
				}
			}
			else
			{
				if (!w[i - 1][j] && w[i][j] && !w[i][j - 1])
					dp[i][j] = dp[i - 1][j] + 1;
				else
					dp[i][j] = dp[i - 1][j];
			}
		}
	}
	cout << dp[n][m];
}

Measured memory_bytes: 384
#include <stdio.h>
int main()
{
    int A,B,C,D,S,max;
    scanf("%d%d%d%d",&A, &B, &C, &D);
    if(A>=C)
    {
        if(B>=D)
            S = D-A;
        else
            S= B-A;
    }
    else
    {
        if(B>=D)
            S = D-C;
        else
            S= B-C;
    }
    if(S>=0)
        max=S;
    else
        max= 0;
    printf("%d",max);
    return 0;
}

Measured memory_bytes: 128
H, W = map(int, input().split())
if (H*W)%3==0:
    print(0)
    exit()
S=[H, W]
x=H//3
a=x*W;b=(H-x)*(W//2);c=(H*W)-a-b
S.append(max([a,b,c])-min([a,b,c]))
x+=1
a=x*W;b=(H-x)*(W//2);c=(H*W)-a-b
S.append(max([a,b,c])-min([a,b,c]))
y=W//3
a=y*H;b=(W-y)*(H//2);c=(H*W)-a-b
S.append(max([a,b,c])-min([a,b,c]))
y+=1
a=y*H;b=(W-y)*(H//2);c=(H*W)-a-b
S.append(max([a,b,c])-min([a,b,c]))
print(min(S))


Measured memory_bytes: 3064
#include <iostream>
#include <math.h>

using namespace std;

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

    int A[N];
    int sumVote = 0;

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

    int count = 0;
    double t = (double)sumVote / (4.0 * (double)M);
    for( int i = 0; i < N; ++i ){
       if( A[i] >= ceil(t) ){
           count += 1;
       } 
    }

    if( count >= M ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;

class node {
public:
  int cost, x, y, d;
  node(int _cost, int _x, int _y, int _d) {
    cost = _cost;
    x = _x;
    y = _y;
    d = _d;
  }
  bool operator > (const node &s) const {
    return cost > s.cost;
  }
};

int main() {
  int dx[] = {0, 1, 0, -1};
  int dy[] = {-1, 0, 1, 0};
  while (true) {
    int w, h;
    cin >> w >> h;
    if (w == 0 && h == 0) {
      break;
    }

    int field[w][h];
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
	cin >> field[j][i];
      }
    }
    int d[4];
    for (int i = 0; i < 4; i++) {
      cin >> d[i];
    }

    int memo[w][h][4];
    memset(memo, -1, sizeof(memo));
    memo[0][0][1] = 0;
    priority_queue <node, vector<node>, greater<node> > pque;
    pque.push(node(0, 0, 0, 1));
    while (!pque.empty()) {
      node p = pque.top(); pque.pop();

      for (int i = 0; i < 4; i++) {
	int nd = (i+p.d)%4;
	int nx = p.x+dx[nd];
	int ny = p.y+dy[nd];

	if (nx < 0 || ny < 0 || nx >= w || ny >= h) {
	  continue;
	}
	if (field[p.x][p.y] == i) {
	  if (memo[nx][ny][nd] == -1 ||
	      memo[nx][ny][nd] > memo[p.x][p.y][p.d]) {
	    memo[nx][ny][nd] = memo[p.x][p.y][p.d];
	    pque.push(node(memo[nx][ny][nd], nx, ny, nd));
	  }
	}else {
	  if (memo[nx][ny][nd] == -1 ||
	      memo[nx][ny][nd] > memo[p.x][p.y][p.d]+d[i]) {
	    memo[nx][ny][nd] = memo[p.x][p.y][p.d]+d[i];
	    pque.push(node(memo[nx][ny][nd], nx, ny, nd));
	  }
	}
      }
    }

    std::cout << min(memo[w-1][h-1][1], memo[w-1][h-1][2]) << std::endl;
  }
}

Measured memory_bytes: 1332
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
	char word[11] = {0};
	char text[1001] = {0};
	int count = 0;
	int i;

	scanf("%s", word);
	for (i = 0; i < 11; i++){
		word[i] = tolower(word[i]);
	}

	for (;;){
		scanf("%*c%s", text);
		if (strcmp(text, "END_OF_TEXT") != 0){
			for (i = 0; i < 1001; i++){
				text[i] = tolower(text[i]);
			}
			if (strcmp(word, text) == 0){
				count++;
			}
			memset(text, '\0', 1001);
		}
		else{
			break;
		}
	}

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

	return 0;
}

Measured memory_bytes: 552
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import org.w3c.dom.ls.LSInput;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int height = sc.nextInt();
		int width = sc.nextInt();
		int remHeight = 0;
		int remWidth = 0;
		
		List<List<Integer>> listHeight = new ArrayList<>();
		
		//図の作成
		for(int cntHeight = 0 ; cntHeight < height ; cntHeight++){
			String str = sc.next();
			List<Integer> listWidth = new ArrayList<>();
			for(int cntWidth = 0 ; cntWidth < width ; cntWidth++){				
				char chr = str.charAt(cntWidth);
				int a=0;
				if(chr == '#'){
					a=1;
				}		
				listWidth.add(a);
			}
			listHeight.add(listWidth);
		}
		sc.close();

		//横一列が同じだったら削除
		for(int cntHeight = height-1 ; cntHeight > -1 ; cntHeight--){
			int sum = 0;
			for(int cntWidth = 0 ; cntWidth < width ; cntWidth++){				
				sum = sum + listHeight.get(cntHeight).get(cntWidth);			
			}
			if(sum == 0){
				listHeight.remove(cntHeight);
				height--;
			}
		}
		
		//縦一列が同じだったら削除
		for(int cntWidth = width-1 ; cntWidth > -1 ; cntWidth--){
			int sum = 0;
			for(int cntHeight = 0 ; cntHeight < height ; cntHeight++){
				sum = sum + listHeight.get(cntHeight).get(cntWidth);
			}
			
			if(sum == 0){
				for(int cntHeight = 0 ; cntHeight < height ; cntHeight++){
					listHeight.get(cntHeight).remove(cntWidth);					
				}
				width--;
			}
		}
		
		for(int cntHeight = 0 ; cntHeight < height ; cntHeight++){
			for(int cntWidth = 0 ; cntWidth < width ; cntWidth++){	
				if(listHeight.get(cntHeight).get(cntWidth)==1){
					System.out.print("#");
				}else{
					System.out.print(".");
				}
			}
			System.out.println("\n");
		}
	}
}

Measured memory_bytes: 24652
import java.util.Scanner;

class Main {

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

		int n = sc.nextInt();

		long ans = getLucasNumber(2, 1, n);
		System.out.println(ans);


		sc.close();
	}

	static long getLucasNumber(long l0, long l1, int n) {
		if (n == 0) {
			return l0;
		}
		n--;
		return getLucasNumber(l1, l0 + l1, n);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  int mod = 0;
  cin >> a; // total
  cin >> b; // 1yen
  
  mod = a % 500;
  
  if(mod <= b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  bool flag=true;
  string str;
  int i;
  cin >> str;
  for (i=0;i<3;i++){
    if(str.at(i)=='7'){
      cout  << "Yes" <<endl;
      flag =false;
      break;
    }
  }
  if (flag)
    cout << "No" <<endl;
}  

Measured memory_bytes: 3572
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    for(int i = 0;i<n;i++){
        if(s[i]=='.') cnt++;
    }
    int ans = cnt;
    for(int i = 0;i<n;i++){
        if(s[i]=='.') cnt--;
        else cnt++;
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <vector>
#include <cmath>
#include <map>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <set>
#include <stack>
#include <bitset>
#include <functional>
#include <ctime>
#include <queue>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
typedef long long LL;

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

int main() {
    LL N, K;
    LL A[100010] = {};
    LL B[100010] = {};
    cin >> N >> K;
    REP(i, N) cin >> A[i] >> B[i];
    LL ans = 0;

    {
        LL sub = 0;
        LL mask = 0;
        for(int k = 0; k < 30; k++) {
            if((K >> (29 - k) & 1) != 0) {
                mask |= (1 << (29 - k));
            }
        }
        for(int j = 0; j < N; j++) {
            LL a = A[j];
            LL b = B[j];
            if((mask | a) == mask) {
                sub += b;
            }
        }
        ans = max(ans, sub);
    }

    for(int i = 0; i < 30; i++) {
        if(K >> (29 - i) & 1) {
            LL sub = 0;
            LL mask = 0;
            for(int k = 0; k < 30; k++) {
                if(k < i && (K >> (29 - k) & 1) != 0) {
                    mask |= (1 << (29 - k));
                } else if(k > i) {
                    mask |= (1 << (29 - k));
                }
            }
            for(int j = 0; j < N; j++) {
                LL a = A[j];
                LL b = B[j];
                if((mask | a) == mask) {
                    sub += b;
                }
            }
            ans = max(ans, sub);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;

const ll MOD = 2019;


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

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (i % 2 == 1) {
			continue;
		}

		
		if (a % 2 == 1) {
			
			cnt++;
		}
	}
	cout << cnt;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, K;
  cin >> N >> K;
  int ans = 0;
  while (N) {
    N /= K;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <map>
#include <string>

std::map<char, int> m;
std::string str;

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

    for(auto&& c : str) ++m[c];
    
    for(auto&& p : m) if(p.second % 2 != 0) {
        std::cout << "No" << std::endl;        
        
        return 0;
    }
    
    std::cout << "Yes" << std::endl;
}

Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int, input().split())) for _ in range(n)]
count=0
for i in a:
    sum=0
    for j in range(m):
        sum+=i[j]*b[j]
    if sum>-c:
        count+=1

print(count)


Measured memory_bytes: 62272
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

string s;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s;
	sort(s.begin(), s.end());
	if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 256
let string_to_bytes s =
  let b = Bytes.create (String.length s) in
  Bytes.iteri (fun i c -> Bytes.set b i s.[i]) b;
  b

let solve s =
  let b = string_to_bytes s in
  Bytes.set b 3 '8';
  Bytes.to_string b

let _ = read_line () |> solve |> print_endline

Measured memory_bytes: 384
s = list(input())
if s[0] == '?':
  s[0] = "D"
for i in range(1, len(s)-1):
  if s[i] == '?':
    if s[i-1]== 'D' and (s[i+1] == 'D' or s[i+1] == '?'):
      s[i] = 'P'
    else: 
      s[i] = 'D'
if s[len(s)-1] == '?':
  s[len(s)-1] = 'D'
print("".join(s))

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

#define N_MAX 100002

using namespace std;

int n;

int a[N_MAX];

long long s;

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        if(a[i - 1] == 1 && a[i] > 0)
        {
            a[i]--;
            s++;
        }
        s += a[i] / 2;
        a[i] %= 2;
    }
    cout << s << "\n";
    return 0;
}


Measured memory_bytes: 640
process.stdin.resume();
process.stdin.setEncoding('utf8');
let input = '';
process.stdin.on('data', function(chunk) {input += chunk;});
process.stdin.on('end', function() {main(input.split(/\r?\n/));});

function partition(A,p,r) {
	let x = A[r];
	let i = p - 1;
	let tmp;
	for (let j = p; j < r; j++) {
		if (A[j] <= x) {
			i++;
			tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}
	i++;
	tmp = A[i];
	A[i] = A[r];
	A[r] = tmp;

	return i;
}

function main(lines){
	let n = Number(lines[0]);
	let A = lines[1].split(" ").map(Number);
	let target = partition(A,0,n-1);

	A[target] = `[${A[target]}]`;

	console.log(A.join(" "));	
}



Measured memory_bytes: 32504
if __name__ == '__main__':
    N = int(input())
    a = input()
    a = a.split(' ')
    a = list(map(int, a))

    min_a = min(a)
    max_a = max(a)

    num = []

    for i in range(max_a+1):
        num.append(0)

    for i in a:
        if i-2 >= 0:
            num[i-2] += 1
        if i-1 >= 0:
            num[i-1] += 1
        num[i] += 1

    c = max(num)
    print(c)

Measured memory_bytes: 14004
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
int main(){
    int N; cin >> N;
    int H[N]; 
    for(int i = 0; i < N; i++){
        cin >> H[i];
    }

    reverse(H,H+N);
    for(int i = 1; i < N; i++){
        if (H[i-1] >= H[i]){
            continue;
        } else {
            H[i]--;
            if (H[i-1] < H[i]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
n, m = [int(i) for i in input().split()]

def init_img(n):
    return [[0 if j == "#" else 1 for j in input()] for i in range(n)]

img = init_img(n)

tmp_img = init_img(m)

flg = False

for i in range(n):
    if flg:
        break

    if i+m > n:
        break

    for j in range(n):
        count = 0
        if j+m > n:
            break
        
        for k in range(m):
            if img[i+k][j:j+m] == tmp_img[k]:
                count += 1

        if count == m:
            flg = True

if flg:
    print("Yes")
else:
    print("No")


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


long MAX = 100005;
long INF = 1234567890;
class DisjointSet{
public:
  vector<int> rank, p;

  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size, 0);
    p.resize(size, 0);
    for(int i=0;i<size;i++) makeSet(i);
  }

  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
  }
  bool same(int x, int y){
    return findSet(x)==findSet(y);
  }

  void unite(int x, int y) {
    link(findSet(x),findSet(y));
  }

  void link(int x, int y){
    if(rank[x]>rank[y]){
      p[y]=x;
    }else{
      p[x]=y;
      if(rank[x]==rank[y]){
        rank[y]++;
      }
    }
  }

  int findSet(int x){
    if(x!=p[x]){
      p[x]=findSet(p[x]);
    }
    return p[x];
  }
};

class Edge{
public:
  int source, target, cost;
  Edge(int source=0,int target=0, int cost=0):
  source(source),target(target),cost(cost){}
  bool operator<(const Edge &e) const{
    return cost<e.cost;
  }
};

int Kruskal(int N,vector<Edge> edges){
  int totalCost=0;
  sort(edges.begin(),edges.end());
  DisjointSet dset = DisjointSet(N+1);
  for(int i=0;i<N;i++) dset.makeSet(i);
  int source, target;
  for(int i=0;i<edges.size();i++){
    Edge e =edges[i];
    if(!dset.same(e.source,e.target)){
      totalCost+=e.cost;
      dset.unite(e.source,e.target);
    }
  }
  return totalCost;
}

int main(){
  int N,M,cost;
  int source,target;
  cin>>N>>M;

  vector<Edge> edges;
  for(int i=0;i<M;i++){
    cin>>source>>target>>cost;
    edges.push_back(Edge(source,target,cost));
  }

  cout<<Kruskal(N,edges)<<endl;
}



Measured memory_bytes: 5480