akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ULL unsigned long long
#define LL long long

using namespace std;

int main(){
	ULL N,sum;
	cin >> N;
	
	sum=N*(N+1)/2;
	sum-=(3*(N/3)*(N/3+1)/2+5*(N/5)*(N/5+1)/2-15*(N/15)*(N/15+1)/2);
	
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
      int n,k,x,y,sum=0,i;
      scanf("%d%d%d%d",&n,&k,&x,&y);

      if(n<=k)
      {
           for(i=1;i<=n;i++)
      {
          sum+=x;
      }
      printf("%d\n",sum);
      }

      else
        {
           for(i=1;i<=k;i++)
      {
          sum+=x;
      }
            for(i=1;i<=n-k;i++)
        {
            sum+=y;
        }
        printf("%d\n",sum);
        }
}


Measured memory_bytes: 1736
n,x=map(int,input().split())
l,p=[1],[1]
for i in range(n):
  l+=[l[-1]*2+3]
  p+=[p[-1]*2+1]
x-=1
a=0
while x>0 and n:
  t=l[n]//2
  if x>=t:
    a+=p[n-1]+1
    x-=t
  x-=1
  n-=1
if x>=0 and n==0: a+=1
print(a)

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

#define ff first
#define ss second
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)
#define foo(a,b) for(int i = int(a);i <= int(b);i++)
#define mk make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define fastio ios_base:: sync_with_stdio(false)


const int MAXN = 1e6;
const int mod = 1e9 + 7;
const int inf = 1e9;

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

	else return gcd(b,a%b);
} 

ll no_of_multiples(ll l,ll r,ll v){
	ll num1 = ceil((long double) l/v);
	ll num2 = floor((long double) r/v);

	return (ll)num2 - num1 + 1;
}

int main(){

	
	fastio;
	ll a,b;
	ll c,d;

	cin >> a >> b >> c >> d;

	ll l =  ((ll)c*d)/( (ll)gcd(c,d));

	ll num1 = no_of_multiples(a,b,c);
	ll num2 = no_of_multiples(a,b,d);
	ll num3 = no_of_multiples(a,b,l);

	ll num = num1 + num2 - num3;

	ll ans = (b-a+1) - num;

	cout << ans << endl;

	return 0;
 }	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)
const int N = 3000, M = 7 + 1e9;
int n, a[N];
ll dp[N][N][2];
ll cal(int i, int j, int p){
	if( i == j ){
		if(p)
			return a[i];
		return -a[i];
	}
	ll &ret =  dp[i][j][p];
	if(~ret)
		return ret;
	if(p==0){
		return ret = min(cal(i+1, j, !p)-a[i], cal(i, j-1, !p)-a[j]);
	}else{
		return ret = max(cal(i+1, j, !p)+a[i], cal(i, j-1, !p)+a[j]);
	}
}
int main()
{
	memset(dp, -1, sizeof dp);
	cin >> n;
	f(i, 0, n)
		cin >> a[i];
	f(i, 0, n)
		dp[i][i][0] = -a[i]; // of length 1
	f(i, 0, n)
		dp[i][i][1] = a[i];
	
	f(i, 2, n+1){//all continous with len i
		f(j, 0, n-i+1){
			int r = j, l = j+i-1;
			dp[r][l][0] = min(dp[r+1][l][1]-a[r], dp[r][l-1][1]-a[l]);
			dp[r][l][1] = max(dp[r+1][l][0]+a[r], dp[r][l-1][0]+a[l]);
		}
	}
	cout << dp[0][n-1][1];
 
}

Measured memory_bytes: 140928
#include<bits/stdc++.h>
#define int long long int
#define endl "\n"
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define mem(a,b) memset(a,b,sizeof(a))
#define loop(i,n) for(int i=0;i<(n);i++)
#define fors(a,b,i) for(int i=(a);i<=(b);i++)
#define ford(a,b,i) for(int i=(a);i>=(b);i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fastm_fast ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL)
using namespace std;
const int  mod = 1e9 + 7;
#define pb push_back
#define mp make_pair
#define S second
#define F first
const int MAX = 1e5;
void sujho()
{
   
   
   int n;
   cin >> n;
   
   vector<int> v(n+1);
   
   loop(i,n) cin >> v[i+1];
   
   vector<int> dp(n+1,INT_MAX);
   
   dp[0] = 0;
   
   dp[1] = 0;
   
   dp[2] = dp[1] + abs(v[2] - v[1]);
   
   for(int i = 3; i <= n; i++)
   {
      dp[i] = min(dp[i-1] +abs(v[i] - v[i-1]) , dp[i-2]+abs(v[i] - v[i-2]) );
   }
   cout<<dp[n]<<endl;
   
   
   
   
}
int32_t main()
 {
 fastm_fast;
//  int tt;
//  cin >> tt;
//  while(tt--)
  {
    sujho();
 }
 return 0;
 }

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int r = 0;
	for (int i = 0; i < 3; i++) {
		int v; cin >> v;
		r = 10 * r + v;
	}
	cout << (r % 4 == 0 ? "YES" : "NO") << '\n';

	return 0;
}


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

using namespace std;

int main() {
    double  N, M, sum, count;
    cin >> N >> M;
    sum = 0;
    count = 0;

    vector<long long> A(N);
    for(int i=0; i<N; i++){
        cin >> A.at(i);
        sum = A.at(i) + sum;
    }

    for(int i=0; i<N; i++){
        if(A[i] >= sum / (4*M)){
        count=count+1;
        }
    }

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


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

int main(){

	string str;
	
	cin >> str;
	
	std::istringstream stream(str);
	for(int i=str.length()-1; i>=0; i--){
		stream >> str[i];
	}

	cout << str << endl;

	return 0;
}

Measured memory_bytes: 1188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


		String[] tmpArray = br.readLine().split(" ");

		int n = Integer.parseInt(tmpArray[0]);
		int d = Integer.parseInt(tmpArray[1]);

		int input[][] = new int[n][d];

		HashSet<Integer> square = new HashSet<Integer>();

		for(int i = 0; i < 150; i++){
			square.add(i*i);
		}
		for(int i = 0; i < n; i++){
			tmpArray = br.readLine().split(" ");

			for(int j = 0; j < d; j++){
				input[i][j] = Integer.parseInt(tmpArray[j]);
			}
		}

		int count = 0;

		for(int i = 0; i < n; i++){
			for(int j = i + 1; j < n; j++){
				int distSq = 0;

				for(int k = 0; k < d; k++){
					distSq += Math.pow(input[i][k] - input[j][k], 2);
				}

				if(square.contains(distSq)){
					count++;
				}
			}
		}

		System.out.println(count);
	}

}


Measured memory_bytes: 21460
import java.util.Scanner;
import java.io.*;

class Main {
    public static void main(String[] args)throws IOException{ 
    	InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader read = new BufferedReader(in);

        String line = read.readLine();
        String [] spli = line.split(" ");
        double a = Double.parseDouble(spli[0]);
        double b = Double.parseDouble(spli[1]);
        double angle = Double.parseDouble(spli[2]);
        double rad = Math.toRadians(angle);    
        double area = 0;
        double circum = 0;
        double hight = 0;
        
        if(angle == 90){
        	area = a*b/2;
        	circum = Math.sqrt(a*a+b*b)+a+b;
        	hight = b;
        }
        else{
        	area = a*b*Math.sin(rad)/2;
            circum = a+b+Math.sqrt(a*a+b*b-2*a*b*Math.cos(rad));
            hight = b*Math.sin(rad);         
        }
        System.out.println(area);
        System.out.println(circum);
        System.out.println(hight);         
    }
}

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

int N, K;
int f[1121][15];
vector< int > prime;

void preprocess(void);

int main() {
  preprocess();
  while (cin >> N >> K, N + K)
    cout << f[N][K] << "\n";

  return 0;
}

void preprocess(void) {
  static bool is_prime[1120];

  prime.push_back(2);
  fill(&is_prime[0], &is_prime[1120], true);
  for (int i = 3; i < 1120; i += 2)
    if (is_prime[i]) {
      prime.push_back(i);
      for (int j = i; i * j < 1120; ++j)
        is_prime[i * j] = false;
    }

  f[0][0] = 1;
  for (int p = 0; p < prime.size(); ++p)
    for (int i = 1120 - prime[p]; i >= 0; --i)
      for (int j = 13; j >= 0; --j)
        f[i + prime[p]][j + 1] += f[i][j];
}

Measured memory_bytes: 1284
#include<algorithm>
#include <bits/stdc++.h>
using namespace std;
int main(void){
	string ans,ans1,ans2,s1,s2,s3,a="ABCDEFGHIJKLMNOPQRSTUVWXYZ",b="abcdefghijklmnopqrstuvwxyz";
	cin>>s1>>s2>>s3;
	for(int i=0;i<a.size();i++){
      //cout<<b[i]<<endl;
      if(s1[0]==b[i]) ans=a[i];
      if(s2[0]==b[i]) ans1=a[i];
      if(s3[0]==b[i]) ans2=a[i];
    }
  	cout<<ans<<ans1<<ans2<<endl;
  	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){

  string s; cin >> s;
  if(s[0] == 'S'){
    cout << "Cloudy" << endl;
  } else if(s[0] == 'C') {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

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

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

struct UnionFind{
    vector<int> d;
    UnionFind(int n = 0):d(n,-1){};

    int find(int x){
        if(d[x] < 0) {
            return x;
        }
        else{
            return d[x] = find(d[x]);
        }
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);

        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    int size(int x){
        return -d[find(x)];
    }

};

struct mint {
    ll x;

    mint(ll x) : x((x % MOOD + MOOD) % MOOD) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
        if ((x += a.x) >= MOOD) x -= MOOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOOD-a.x) >= MOOD) x -= MOOD;
        return *this;
    }

    mint &operator*=(const mint a) {
        if ((x *= a.x) %= MOOD);
        return *this;
    }

    mint operator+(const mint a)const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const{
        if(!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if(t&1) a *= *this;
        return a;
    }

    mint inv() const {
        return pow(MOOD-2);
    }

    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }

};

mint kaijyo(int n) {
    if (n == 0) return 1;
    mint x = kaijyo(n/2);
    x *= x;
    if (n%2 == 1) x *= 2;
    return x;
}

mint choose(int n, int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x / y;
}

int main() {
    int N;
    scanf("%d",&N);
    int check;
    int count = 0;

    rep(i,N){
        scanf("%d",&check);
        if(check % 2 == 0){
            if(check % 3 == 0 || check % 5 == 0){}
            else{
                count = -1;
            }
        }
    }

    if(count == -1){
        printf("DENIED");
    }
    else{
        printf("APPROVED");
    }

    return 0;
}

int A(){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(A==B && A !=C){
        printf("Yes");
    }
    else if(A==C && C != B){
        printf("Yes");
    }
    else if(B==C && C != A){
        printf("Yes");
    }
    else{
        printf("No");
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    char  o[55],e[55];
    int i;
    scanf("%s %s",o,e);
    for(i=0;o[i]!='\0';i++){
        if(o[i]=='\0'&&e[i]=='\0') break;
        else if (e[i]=='\0') printf("%c",o[i]);
        else printf("%c%c",o[i],e[i]);
    }
    return 0;
}

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

main(){
int N = 0;
int L = 0;
  cin >> N;
  cin >> L;
  
  if(L > 0){
  cout << ((L + 1) + (L + N - 1)) * (N - 1) / 2 << endl;
  }
  if(L + N < 1){
  cout << (L + (L + N - 2)) * (N - 1) / 2 << endl;
  }
  if(L < 1 && L + N > 0){
  cout << (L + (L + N - 1)) * N / 2 << endl;
  }
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] s=br.readLine().split(" ");
        double a=Double.parseDouble(s[0]);
        double b=Double.parseDouble(s[1]);
        double C=Math.toRadians(Double.parseDouble(s[2]));
        double h=b*Math.sin(C);
        System.out.printf("%.8f%n", a*h/2);
        System.out.printf("%.8f%n", a+b+Math.sqrt(a*a+b*b-2*a*b*Math.cos(C)));
        System.out.printf("%.8f%n", h);
	}
}

Measured memory_bytes: 16944
#include<stdio.h>

int main()
{
	int mount[10],i,j,l;
	
	for(i=0;i<10;i++)
	{
		scanf("%d",&mount[i]);
	}
	for(i=0;i<3;i++)
	{
		for(j=i+1;j<10;j++)
		{
			if(mount[i]<mount[j])
			{
				l=mount[i];
				mount[i]=mount[j];
				mount[j]=l;
			}
		}
	}
	for(i=0;i<3;i++)
		printf("%d\n",mount[i]);
	return 0;
}

Measured memory_bytes: 0
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

x,y,a,b,c = nm()
p = nl()
q = nl()
r = nl()
p.sort()
q.sort()
l = p[-x:] + q[-y:]
l.sort()
r.sort()
for i in range(min(x+y, c)):
    if l[i] < r[-1]:
        l[i] = r.pop()
    else:
        break
print(sum(l))


Measured memory_bytes: 23472
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template


def main():
    N = ii()
    S = li()
    flag = True
    if N % 2 == 1:
        exit("No")
    for i in range(N // 2):
        if S[i] != S[i + N // 2]:
            flag = False
    if flag:
        print("Yes")
    else:
        print("No")
    return


if __name__ == '__main__':
    main()


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

#define ASC(vec) vec.begin(), vec.end() 
#define DESC(vec) vec.rbegin(), vec.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, vec.size()) cin>>vec[i]; 
#define ANS(s) cout << s << endl;
#define inc(a, b) cin >> a >> b;

int main(){
	int n,k,q;
	cin>>n>>k>>q;
	vector<int> tamesi (n,0);
	vector<int> tamesi1 (q);
	In(tamesi1);

	for(auto v : tamesi1){
			tamesi[v-1] = tamesi[v-1]+1;
 	}

	for(auto v: tamesi){
			if(k-q+v>=1) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 4048
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int h,w;
  while(cin>>h>>w,h||w){
    int a=h*h+w*w;
    bool hantei=false;
    while(1){
      while(1){
	h++;
	double s=sqrt(a-h*h);
	if(s-(int)s==0&&h*h<(a-h*h)){hantei=true;break;}
	if(a-h*h<1)break;
      }
      //cout<<a<<endl;
      if(hantei){cout<<h<<" "<<sqrt(a-h*h)<<endl;break;}
      a++;
      h=0;
    }
  }
}

Measured memory_bytes: 1244
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a;
	int b;
	int c;
	int d;
	int e;
	std::cin >> a >> b >> c;
	if (a <= c && b >= c) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}
	std::cin >> e;
}

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

int m,a,b,c,t;

int main(){
    string s;
    cin>>s;
    m=s.size();
    for(int i=0;i<m;i++){
        if(s[i]=='a') a++;
        else if(s[i]=='b') b++;
        else if(s[i]=='c') c++;
    }
    t=min(a,min(b,c));
    a-=t;b-=t;c-=t;
    if(a>=2||b>=2||c>=2) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define sPRINT(str) printf(#str "\n")
#define yOUT sPRINT(Yes)
#define nOUT sPRINT(No)
#define YOUT sPRINT(YES)
#define NOUT sPRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
 
using namespace std;

int main(void)
{   
    int w, a, b;
    cin >> w >> a >> b;
    if((a <= b && b <= a+w) || (a <= b+w && b+w <= a+w)){
        cout << 0 << endl;
    }
    else{
        if(a < b){
            cout << b - (a + w) << endl;
        }
        else{
            cout << a - (b + w) << endl;
        } 
    }
}


Measured memory_bytes: 256
#include<stdio.h>
typedef struct duitype
{
	long x,y,z;
}duitype;
duitype dui[1000000];
long jl[7][7][7][7][7][7];
bool bj[11][11][1000];
long temp[7];
long vv[7];
long v[46657][7];
long have[11][11][1000];
long aa,a1,b1,c1,d1,e1,f1,a2,b2,head,last,x,y,z,top,i,ans,k,j,place,zz,n,m;
long map[105][105];
void cha(long a,long b,long c,long d)
{
	long t;
	t=temp[a];
	temp[a]=temp[b];
	temp[b]=temp[c];
	temp[c]=temp[d];
	temp[d]=t;
}
long change(long z,char c)
{
	long i;
	for (i=1;i<=6;i++)
	  temp[i]=v[z][i];
	switch(c)
	{
		case 'u':cha(6,3,4,5);break;
		case 'd':cha(4,3,6,5);break;
		case 'r':cha(1,5,2,3);break;
		case 'l':cha(1,3,2,5);break;
	}
	return jl[temp[1]][temp[2]][temp[3]][temp[4]][temp[5]][temp[6]];
}
void ind(long x,long y,long z,long all,char c)
{
	long ne;
  if (x<=0 || x>n || y<=0 || y>m)
    return;
	ne=change(z,c);
  if (have[x][y][ne]>all+vv[v[ne][5]]*map[x][y])
	{
	  have[x][y][ne]=all+vv[v[ne][5]]*map[x][y];
		if (!bj[x][y][ne]){
			bj[x][y][ne]=true;
			last++;
			dui[last].x=x;
			dui[last].y=y;
			dui[last].z=ne;
		}
	} 
	if (x==a2 && y==b2)
	  if (ans>have[x][y][ne])
	  {
	    ans=have[x][y][ne];
	  }
}
int main()
{
	top=0;
	for (a1=1;a1<=6;a1++)
	  for (b1=1;b1<=6;b1++)
  		if (b1!=a1)
	    	for (c1=1;c1<=6;c1++)
	      	if (c1!=a1 && c1!=b1)
						for (d1=1;d1<=6;d1++)
	        		if (d1!=a1 && d1!=b1 && d1!=c1)
								for (e1=1;e1<=6;e1++)
		          		if (e1!=a1 && e1!=b1 && e1!=c1 && e1!=d1)
  	  	        		{
  	  	        			f1=21-a1-b1-c1-d1-e1;
    	  	      			top++;jl[a1][b1][c1][d1][e1][f1]=top;
      	  	    			v[top][1]=a1;v[top][2]=b1;v[top][3]=c1;v[top][4]=d1;v[top][5]=e1;v[top][6]=f1;
        	  	  		} 
  while (scanf("%d %d",&n,&m)==2){
  	if (n==0)
  	  return 0;
  	for (i=1;i<=n;i++)
    	for (j=1;j<=m;j++)
      	for (k=1;k<=top;k++){
        	have[i][j][k]=10000000;
      	  bj[i][j][k]=false;
				}
	  ans=10000000;
  	for (i=1;i<=n;i++)
    	for (j=1;j<=m;j++)
      	scanf("%d",&map[i][j]);
 	  scanf("%d%d%d%d",&a1,&b1,&a2,&b2);
  	a1++;a2++;b1++;b2++;
  	vv[1]=4;vv[2]=3;vv[3]=1;vv[4]=2;vv[5]=6;vv[6]=5;
		z=zz=jl[1][2][3][4][5][6]; 
  	head=0;last=1;dui[1].x=a1;dui[1].y=b1;dui[1].z=z;
  	have[a1][b1][z]=0;
  	while (head<last)
  	{
  		head++;
  		x=dui[head].x;y=dui[head].y;z=dui[head].z;
  	  bj[x][y][z]=false;
			ind(x+1,y,z,have[x][y][z],'d');
    	ind(x-1,y,z,have[x][y][z],'u');
  	  ind(x,y+1,z,have[x][y][z],'r');
    	ind(x,y-1,z,have[x][y][z],'l');
		}
		printf("%ld\n",ans);
  }
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#define INF 1000000001

using namespace std;
typedef long long int ll;

int main()
{
	int n, k, q;
	scanf("%d %d %d", &n, &k, &q);
	int a[2000];
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	int ans=INF;
	for(int t=0; t<n; t++){
		int a0=a[t];
		vector<int> v, v0;
		for(int i=0; i<n; i++){
			if(a[i]<a0){
				if(v.size()<k){
					v.clear();
					continue;
				}
				sort(v.begin(), v.end());
				for(int j=0; j<=v.size()-k; j++){
					v0.push_back(v[j]);
				}
				v.clear();
			}else{
				v.push_back(a[i]);
			}
		}
		if(v.size()>=k){
			sort(v.begin(), v.end());
			for(int j=0; j<=v.size()-k; j++){
				v0.push_back(v[j]);
			}
		}
		if(v0.size()<q) continue;
		sort(v0.begin(), v0.end());
		if(ans>v0[q-1]-a0) ans=v0[q-1]-a0;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){

  int i,j;
  int x,N;
  int s,max;

  scanf("%d",&x);

  N = (sqrt(x));

  i = 1;
  max = 1;

  for(i=2;i<N+1;i++){
    s = i;

    while(s<=x){
      s = s * i;
    }

    s = s/i;

    if(s > max)max = s;
    }
  

  printf("%d", max);
  return 0;
}

Measured memory_bytes: 128
use proconio::input;
// result = R...RW...W
fn main() {
    input! {
        n: usize,
        c: String,
    }
    let c: Vec<_> = c.chars().collect();
    let (mut lw, mut rr) = (vec![0; n + 1], vec![0; n + 1]);
    rr[0] = c.iter().filter(|&x| x == &'R').count();
    for i in 0..n {
        rr[i + 1] = rr[i];
        lw[i + 1] = lw[i];
        match c[i] {
            'R' => rr[i + 1] -= 1,
            'W' => lw[i + 1] += 1,
            _ => unreachable!(),
        }
    }

    println!(
        "{:?}",
        (0..=n)
            .map(|i| {
                let swap = std::cmp::min(lw[i], rr[i]);
                let change_r = std::cmp::max(rr[i] - swap, 0);
                let change_l = std::cmp::max(lw[i] - swap, 0);
                swap + change_r + change_l
            })
            .min()
            .unwrap()
    );
}


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

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll sol = 0;
    for(int i = 0; i < n; i++){
        if((i + 1) % 3 != 0 && (i + 1) % 5 != 0)
            sol += i + 1;
    }
    cout << sol;
}

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,m;
int a[190][190],d[190][190][190][17],opt[190][17];
char s[190][190];

int getpl(int k,int i,int j){
	int l=k,r=m,ret=k-1;
	while(l<=r){
		int mid=(l+r)/2,sum=a[j][mid]-a[i-1][mid]-a[j][k-1]+a[i-1][k-1];
		if(sum==0||sum==(mid-k+1)*(j-i+1)) ret=mid,l=mid+1;
		else r=mid-1;
	}
	return ret;
}

int main(){
	n=readint(); m=readint();
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1]+(s[i][j]=='#');
	for(int k=m;k>=1;k--){
		for(int i=1;i<=n;i++) for(int j=1;j<=16;j++) opt[i][j]=i-1;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n-i+1;j++){
				int l=j,r=j+i-1;
				d[k][l][r][0]=getpl(k,l,r);
				for(int t=1;t<=16;t++){
					d[k][l][r][t]=max(d[k][l][r][t-1],d[d[k][l][r][t-1]+1][l][r][t-1]);
					while(opt[l][t]+1<r&&d[k][l][opt[l][t]+1][t-1]>d[k][opt[l][t]+2][r][t-1]) opt[l][t]++;
					chkmax(d[k][l][r][t],min(d[k][l][opt[l][t]][t-1],d[k][opt[l][t]+1][r][t-1]));
					chkmax(d[k][l][r][t],min(d[k][l][opt[l][t]+1][t-1],d[k][opt[l][t]+2][r][t-1]));
				}
			}
		}
	}
	for(int i=0;i<=16;i++) if(d[1][1][n][i]==m) return printf("%d\n",i),0;
	return 0;
}

Measured memory_bytes: 444800
N = int(input())
l = []
for i in range(N):
  l.append(int(input()))
  
ans = 0
for i in range(N):
  ans += l[i] // 2
  l[i] = l[i] % 2
  if (i<N-1) and (l[i]==1) and (l[i+1]>0):
    ans += 1
    l[i] = 0
    l[i+1] -= 1
print(ans)

Measured memory_bytes: 12984
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    tmp = float("inf")
    ans = 0
    y = float("inf")
    for j in range(m):
        x = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if x < tmp or x == tmp and i < y:
            tmp = x
            ans = j + 1
            y = i
    print(ans)

Measured memory_bytes: 39408
//2018年  3月 21日 水曜日 17:08:21 JST
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
int G[110][110];
int A[1010], B[1010], C[1010];

void solve() {
	cin >> N >> M;
	rep(i, 0, N) {
		rep(j, 0, N) {
			if(i == j) continue;
			G[i][j] = inf;
		}
	}
	rep(i, 0, M) {
		cin >> A[i] >> B[i] >> C[i]; A[i]--; B[i]--;
		G[A[i]][B[i]] = C[i];
		G[B[i]][A[i]] = C[i];
	}
	rep(k, 0, N) {
		rep(i, 0, N) {
			rep(j, 0, N) {
				MIN(G[i][j], G[i][k] + G[k][j]);
			}
		}
	}
	// rep(i, 0, N) 
	// 	rep(j, 0, N) debug(i, j, G[i][j]);
	int ans = 0;
	rep(i, 0, M) {
		int a = A[i], b = B[i], c = C[i];
		bool found = false;
		rep(j, 0, N) {
			rep(k, 0, N) {
				if(j == k) continue;
				if(G[j][a] + c + G[b][k] == G[j][k]) {
					found = true; break;
				}
				if(G[j][b] + c + G[a][k] == G[j][k]) {
					found = true; break;
				}
			}
		}
		if(!found) ans++;
	}
	cout << ans << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string s;
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> s;
    if (s == "Y") {
      cout << "Four" << endl;
      break;
    }
    else if (i == N-1) {
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
N = int(input())
s = [[] for i in range(N)]

s[0].append("a")

def maxs(ss):
    max_ss = 0
    for i in range(len(ss)):
        max_ss = max(max_ss,ord(ss[i]))
    return max_ss

for i in range(1,N):
    for ss in s[i-1]:
        for j in range(97,maxs(ss)+2):
            s[i].append(ss+chr(j))

for ss in s[N-1]:
    print(ss)

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

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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

ll alf[26];
int main()
{
  int N; cin >> N;
  REP(i, N) {
    char c; cin >> c;
    alf[c - 'a']++;
  }
  ll ans = 1;
  REP(i, 26) {
    (ans *= (alf[i] + 1)) %= MOD;
  }
  ans = (MOD + (ans - 1)) % MOD;
  cout << ans << endl;

  return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> A(N);
    rep (i, N) {
        cin >> A[i];
    }

    map<ll, ll> m;
    rep (i, N) {
        m[A[i]]++;
    }

    ll cnt = 0;
    for (auto it : m) {
        if (it.second%2 == 0) {
            cnt++;
        }
    }

    if (cnt%2) {
        cout << m.size()-1 << endl;
    } else {
        cout << m.size() << endl;
    }
    return 0;
}

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

using namespace std;

int main(void){
  map<long long, long long> s;
  long long ans = 0;
  long long N;
  cin >> N;
  for(long long i = 1; i <= N; i++){
    long long A;
    cin >> A;
    ans += s[i - A];
    s[i + A]++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int t, n, ans, x;
string s;
int mx = -9;
int main()
{
cin >> s;
s=s+'#';
for ( int j = 0; j<=3;j++)
{if( s[j] == 'R')
{x++;}
else 
{mx = max( x , mx);
x=0;
}
}
	
	cout << mx;

  
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#include <cmath>
#include <cstring>
#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

int A[200000];
    int i, j;
    int N, K;

int main() {
  cin >> N >> K;
  rep0(i, N) cin >> A[i];
 
  int ng = 0, ok = 1e9 + 1;
  while (ok - ng > 1) {
    int m = (ok + ng) / 2;
    int cnt = 0;
    rep0(i, N) { cnt += (A[i] + m - 1) / m - 1; }
    if (cnt <= K)
      ok = m;
    else
      ng = m;
  }
  cout << ok << endl;
  return 0;
}

Measured memory_bytes: 4416
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var x = int.Parse(line[0]);
            var y = int.Parse(line[1]);
            var w = int.Parse(line[2]);
            var h = int.Parse(line[3]);
            var c = int.Parse(Console.ReadLine().Trim());
            var count = 0;
            for (int j = 0; j < c; j++)
            {
                line = Console.ReadLine().Trim().Split(' ');
                var cx = int.Parse(line[0]);
                var cy = int.Parse(line[1]);
                if (cx >= x && cx <= x + w && cy >= y && cy <= y + h) count++;
            }
            Console.WriteLine(count);
        }
    }
}


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

int main(){
  string S;
  cin >> S;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
	  for(int k=0;k<3;k++){
		string tmp = "";
		tmp += S[i];
		tmp += S[j];
		tmp += S[k];
		if(tmp=="abc"){
		  cout << "Yes" << endl;
		  return 0;
		}
	  }
	}
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>
#include<tuple>
#include<numeric>
#include<cassert>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<int,ll>;
using Pd = pair<double,double>;
using T = tuple<double,double,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N = 100005, MAX_C = 30;
const ll lmod = 1e9+7;

vector<Pd> st[MAX_C];
priority_queue<double,vector<double>,greater<double>> s_que,t_que;

int main(){
	int N,C; cin >> N >> C ;
	rep(i,N){
		double s,t; int c;
		scanf("%lf%lf%d",&s,&t,&c);
		c--; st[c].pb(Pd(s,t));
	}
	rep(i,C) sort(ALL(st[i]));
	rep(i,C){
		if(st[i].size()==0) continue;
		rep(j,st[i].size()-1){
			double s1,t1,s2,t2;
			tie(s1,t1) = st[i][j];
			tie(s2,t2) = st[i][j+1];
			if(abs(s2-t1)<=0.5+EPS){
				st[i][j].first = st[i][j].second = 0;
				st[i][j+1].first = s1;
			}
		}
		rep(j,st[i].size()){
			if(st[i][j].first==0&&st[i][j].second==0) continue;
			double s,t; tie(s,t) = st[i][j];
			s_que.push(s-0.5); t_que.push(t);
		}
	}
	int ans,cnt;
	ans = -1;
	cnt = 0;
	while(!(s_que.empty())){
		double s,t;
		s = s_que.top();
		t = t_que.top();
		if(s<t){
			cnt++;
			ans = max(ans,cnt);
			s_que.pop();
		}else{
			cnt--;
			t_que.pop();
		}
	}
	cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4336
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 64;
const int N = (int)2e5 + 7;
const int MAXN = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)2e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e18;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

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

void solve() {
	int l, r, d;
	cin >> l >> r >> d;
	int ans = 0;
	for (int i = l; i <= r; i++)
		ans += i % d == 0;
	cout << ans;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
int main(){
  char s[4];
 
 scanf("%s",s); 
  
  int a=0;
  int b=0;
  int c=0;
  for(int i;i<4;i++){
   if(s[0]==s[i]){
     a=a+1;
   }
    if(s[3]==s[i]){
      b=b+1;
    }
    if(s[2]==s[i]){
      c=c+1;
    }
  }
  if(a==2&&b==2&&c==2){
    
    printf("Yes\n");
  }
  else{
  printf("No\n");
  }
  //printf("%d,%d,%d",a,b,c);
}
    

Measured memory_bytes: 128
<?php
fscanf(STDIN, '%d', $dummy);
$A = explode(' ', trim(fgets(STDIN)));
$array = [];
$ans = true;
foreach ($A as $aa) {
    if (!isset($array[$aa])) {
        $array[$aa] = 1;
    } else {
        $ans = false;
        break;
    }
}
echo $ans ? 'YES' : 'NO';


Measured memory_bytes: 33780
#include <stdio.h>
#include <stdlib.h>


typedef struct pair{
    long long a;
    long long b;
}ab;

//sub function to use qsort //
int compare_int(const void *x, const void *y)
{
    return (*(ab*)x).a - (*(ab*)y).a;
}

int main (void)
{
    long long n,m,i;
    scanf("%lld %lld",&n,&m);
    ab abx[n];
    for (i= 0; i< n; i ++)  {
        scanf("%lld %lld",&abx[i].a,&abx[i].b);   //b ... how many bottles a... money / bottle //
    }
    // input complete //
    qsort(abx, n, sizeof(ab), compare_int);
    int cnt = 0;
    long long money = 0;
    for  (i = 0;; i ++) {
        if (cnt + abx[i].b <= m)  {
            cnt +=  abx[i].b;
            money += abx[i].a * abx[i].b;
        }
        else {
            money += abx[i].a * (m - cnt);
            break;
        }
    }
    printf("%lld",money);
    return 0;
}

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

using namespace std;

int main(void)
{
    int N;
    string s;
    cin >> N >> s;
    int r = 0, b = 0;
    for (auto i: s)
    {
        if (i == 'R') r++;
        else b++;
    }
    cout << ( (r > b) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#####コピペ
def BellmanFord(edges, num_v, source):
    # グラフの初期化
    inf = float("inf")
    dist = [-inf for i in range(num_v)]
    dist[source - 1] = 0

    # 辺の緩和
    buf = 0
    for i in range(num_v * 2):
        for edge in edges:
            if dist[edge[1] - 1] < dist[edge[0] - 1] + edge[2]:
                dist[edge[1] - 1] = dist[edge[0] - 1] + edge[2]
                if i >= num_v:
                    dist[edge[1] - 1] = inf
        if i == num_v - 1:
            buf = dist[-1]
    if dist[-1] != buf or dist[-1] == -inf:
        return -1
    return max(dist[-1], 0)
##########################################################################
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = []

N, M, P = LI()
cou = int(0)
maxC = 10000
d = [[float("inf") for i in range(N)] for i in range(N)]
#d[u][v] : 辺uvのコスト(存在しないときはinf)
V = []*M
for i in range(M):
    a, b, c = list(map(int,input().split()))
    V.append((a,b,c-P))
print(BellmanFord(V, N, 1))

#print(ans)


Measured memory_bytes: 104668
#include <iostream>
using namespace std;
 
int main(){
    int n, l;
    cin >> n;
    int ai[n];
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> l;
        ai[i] = l;
        ans ^= l;
    }
    for(int i = 0; i < n; i++){
        ai[i] ^= ans;
        cout << ai[i] << " ";
    }
    cout << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<string> vec(n);
  
  for(int i = 0;i < n;i ++){
    cin >> vec.at(i);
  }
  
  set<string> S;
  
  for(int i = 0;i < n;i ++){
    S.insert(vec.at(i));
  }
  
  cout << S.size() << endl;
}

Measured memory_bytes: 25012
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long int_;
inline int readint() {
	int a = 0; char c = getchar(), f = 1;
	for(; c<'0' or c>'9'; c=getchar())
		if(c == '-') f = -f;
	for(; '0'<=c and c<='9'; c=getchar())
		a = (a<<3)+(a<<1)+(c^48);
	return a*f;
}
void writeint(int_ x){
	if(x < 0) putchar('-'), x = -x;
	if(x > 9) writeint(x/10);
	putchar((x%10)^48);
}
# define MB template < typename T >
MB void getMax(T &a,const T &b){ if(a < b) a = b; }
MB void getMin(T &a,const T &b){ if(b < a) a = b; }
# define FOR(i,n) for(int i=0; i<(n); ++i)

struct Edge{
	int to, nxt;
	Edge(){}
	Edge(int T,int N):to(T),nxt(N){}
};

const int MaxN = 200005, infty = (1<<30)-1;
int a[MaxN], head[MaxN], n;
Edge edge[MaxN<<1];

int cntEdge;
void addEdge(int x,int b){
	edge[cntEdge] = Edge(b,head[x]);
	head[x] = cntEdge ++;
	edge[cntEdge] = Edge(x,head[b]);
	head[b] = cntEdge ++;
}

int g[MaxN], ans[MaxN], sxy[MaxN];
void dfs(int x,int pre){
	ans[x] = lower_bound(g+1,g+n+1,a[x])-g;
	int origin = g[ans[x]];
	g[ans[x]] = a[x];
	sxy[x] = max(sxy[pre],ans[x]);
	for(int i=head[x]; ~i; i=edge[i].nxt)
		if(edge[i].to != pre)
			dfs(edge[i].to,x);
	g[ans[x]] = origin;
}

int main(){
	cin >> n;
	for(int i=1; i<=n; ++i){
		cin >> a[i];
		head[i] = -1, g[i] = infty;
	}
	for(int i=1; i<n; ++i){
		int p, q; cin >> p >> q;
		addEdge(p,q);
	}
	dfs(1,0);
	for(int i=1; i<=n; ++i)
		cout << sxy[i] << endl;
	return 0;
}


Measured memory_bytes: 18684
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

ll k;

ll dfs(ll num, ll& cnt, bool f, ll d) {
    if (d == 0) {
        if (f) {
            cnt++;
            return (cnt == k) ? num : -1;
        }
        else return -1;
    }
    ll res = 0;
    if (!f) {
        rep(i, 10) {
            chmax(res, dfs(i, cnt, i != 0, d - 1));
        }
    }
    else {
        ll n = num % 10;
        if (n - 1 >= 0) {
            chmax(res, dfs(num * 10 + n - 1, cnt, f, d - 1));
        }
        chmax(res, dfs(num * 10 + n, cnt, f, d - 1));
        if (n + 1 <= 9) {
            chmax(res, dfs(num * 10 + n + 1, cnt, f, d - 1));
        }
    }
    return res;
}

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

    cin>>k;
    ll cnt = 0;
    cout<<dfs(0, cnt, false, 10)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N;
	cin >> N;
	vector<int>L(N);
	rep(i, N) {
		cin >> L[i];
	}
	sort(L);
	reverse(L);
	int A = L[0];
	int sum = 0;
	for (int i = 1; i < N; i++) {
		sum += L[i];
	}
	if (sum > A) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    int[][][] d;
    int[][][] p;
    void run(){
	Scanner sc=new Scanner(System.in);
	while(true){
	    int n=sc.nextInt();
	    if(n==0)break;
	    n+=1;
	    d=new int[n][][];
	    for(int i=0;i<n;i++){
		int m=sc.nextInt();
		int[][] temp=new int[2][m];
		temp[0][0]=0;temp[1][0]=0;
		int preX=sc.nextInt();
		int preY=sc.nextInt();
		for(int j=1;j<m;j++){
		    int x=sc.nextInt();
		    int y=sc.nextInt();
		    temp[0][j]=x-preX;preX=x;
		    temp[1][j]=y-preY;preY=y;
		}
		d[i]=temp;
	    }
	    p=new int[8][2][d[0][0].length];
	    p[0]=d[0];
	    for(int i=0;i<4;i++){
		p[i]=rotate(p[0],i);
	    }
	    int len=p[0][0].length;
	    for(int i=4;i<8;i++){
		p[i][0][0]=0;p[i][1][0]=0;
		for(int j=1;j<len;j++){
		    p[i][0][j]=p[i-4][0][len-j];
		    p[i][1][j]=p[i-4][1][len-j];
		}
	    }
	    for(int i=1;i<n;i++){
		if(solve(d[i]))System.out.println(i);
	    }
	    System.out.println("+++++");
	}
    }
    int[][] rotate(int[][] a,int b){
	int[][] r=new int[2][a[0].length];
	for(int i=0;i<a[0].length;i++){
	    int e[]={a[0][i],a[1][i]};
	    r[0][i]=(b==1||b==2 ? -1:1)*e[b%2];
	    r[1][i]=(b>=2 ? -1:1)*e[1-b%2];
	}
	return r;
    }
    boolean solve(int[][] a){
	for(int i=0;i<8;i++){
	    if(Arrays.equals(a[0],p[i][0])&&Arrays.equals(a[1],p[i][1]))return true;
	}
	return false;
	}
    public static void main(String[] args){
	new Main().run();
    }
}

Measured memory_bytes: 12000
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;

//typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll MAX = 1e9 + 5;

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

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


	}

	vector<string> b(m);
	for (int i = 0; i < m; i++) {
		cin >> b[i];


	}


	for (int i = 0; i <= n - m; i++) {
		for (int j = 0; j <= n - m; j++) {
			bool canExist = true;
			for (int k = 0; k < m; k++) {
				for (int l = 0; l < m; l++) {
					canExist = canExist && (a[i + k][j + l] == b[k][l]);


				}
			}
			if (canExist) {
				cout << "Yes" << endl;
				return 0;
			}

		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

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

    int n = a + b;
    int x;

    if (n % 2 == 0) {
        x = n / 2;
    }
    else {
        x = n / 2 + 1;
    }

    cout << x << endl;
}


Measured memory_bytes: 256