akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)

using namespace std;

int main() {
	int x, y;
	int a, b, c;

	cin >> x >> y >> a >> b >> c;

	ll p[a];
	ll q[b];
	ll r[c];

	rep(i, a) {
		cin >> p[i];
	}
	rep(i, b) {
		cin >> q[i];
	}
	rep(i, c) {
		cin >> r[i];
	}
	sort(&p[0], &p[a]);
	sort(&q[0], &q[b]);
	sort(&r[0], &r[c]);

	int ans[x + y];

	rep(i, x) {
		ans[i] = p[a - i - 1];
	}
	rep(i, y) {
		ans[x + i] = q[b - i - 1];
	}
	sort(&ans[0], &ans[x + y]);
	/*
	cout << "----" << endl;
	rep(i, x + y) {
		cout << ":" << ans[i] << endl; 
	}
	cout << "----" << endl;
	*/
	int cur_r = c - 1;
	rep(i , x + y) {
		if (cur_r < 0) {

			break;
		}
		//cout << r[cur_r] << ":" << ans[i] << endl;
		if (r[cur_r] > ans[i]) {
			//cout << "change" << endl;
			 ans[i] = r[cur_r];
		} else {
			break;
		}
		cur_r--;
	}
	ll total = 0;
	rep(i , x + y) {
		total += ans[i];
	}
	cout << total << endl;

	return 0;

}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline void myassert(bool a,string s){ if(!a)cerr<<s<<endl,exit(0);}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=260;

int n,mod;

int l[maxn],r[maxn];
int R[maxn];

inline void init()
{
	n=read();mod=read();
	REP(i,0,n-1)
	{
		l[i+1]=sqrt(n*n-i*i-1)+1;
		r[i+1]=min((int)sqrt(4*n*n-i*i),2*n-1)+1;
	}
	REP(i,0,n-1)R[i+1]=sqrt(4*n*n-(i+n)*(i+n))+1;
}

int dp[maxn],g[maxn];

inline void doing()
{
	int ans=0;
	REP(t,0,n)
	{
		memset(dp,0,sizeof(dp));
		dp[0]=1;
		int sum1=0,sum2=0;
		for(int i=n,j=n;i>0 || j>0;)
		{
			memset(g,0,sizeof(g));
			if(j==0 || (i>0 && l[i]<R[j]))
			{
				REP(k,0,t)
				{
					if(k<t)g[k+1]=(g[k+1]+(ll)dp[k]*max(l[i]-sum2-k,0))%mod;
					g[k]=(g[k]+(ll)dp[k]*max(r[i]-n-sum1-(t-k),0))%mod;
				}
				sum1++;
				i--;
			}else
			{
				REP(k,0,t)
				{
					g[k]=(g[k]+(ll)dp[k]*(R[j]-k-sum2))%mod;
				}
				sum2++;
				j--;
			}
			memcpy(dp,g,sizeof(g));
		}
		ans=(ans+(t&1?-1:1)*dp[t])%mod;
	}
	ans=(ans+mod)%mod;
	printf("%d\n",ans);
}

int main()
{
	init();
	doing();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int l = s.length();
    int i, p=0;
    for(i=0;i<l;i++){
        p=(p+(s[i]-'0'))%9;
    }
    if(p==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3716
n = int(input())
s = input()

l = [0]*n
r = [0]*n
for i in range(1,n):
    l[i] = l[i-1]+(s[i-1]=="W")
for i in range(n-1)[::-1]:
    r[i] = r[i+1]+(s[i+1]=="E")

ans = 10**6
for a,b in zip(l,r):
    ans = min(a+b,ans)
print(ans)

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

int main() {
string a;
  cin >> a;
  int b=0,bmax=0;
  for (int i=0; i<a.size(); i++){
    if(a.at(i)=='A'||a.at(i)=='G'||a.at(i)=='C'||a.at(i)=='T'){
    b++;
    bmax=max(b,bmax);
    }else {
      b=0;
    }
  }
cout << max(b,bmax) << endl;
}

Measured memory_bytes: 256
from bisect import bisect_left as bl
N = int(input())
P = 998244353
NN = 18
XX = [0] * (2**(NN+1)-1)
pow2 = [1]
for _ in range(1, 202020):
    pow2.append(pow2[-1]*2%P)

def addvalue(j):
    i = 2**NN + j - 1
    while i >= 0:
        XX[i] += 1
        i = (i-1) // 2

def rangesum(a, b):
    l = a + (1<<NN)
    r = b + (1<<NN)
    s = 0
    while l < r:
        if l%2:
            s += XX[l-1]
            l += 1
        if r%2:
            r -= 1
            s += XX[r-1]
        l >>= 1
        r >>= 1
    return s

X = []
Y = []
XY = []
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
    XY.append((x, y))

X = sorted(X)
Y = sorted(Y)
XY = sorted(XY, key = lambda x: x[1])

DX = {}
for i in range(N):
    DX[X[i]] = i

ans = 0
U = 0
for x, y in XY:
    a = rangesum(0, DX[x])
    L = bl(X, x)
    b = U-a
    d = L-a
    c = N-a-b-d-1
    ans = (ans + pow2[N] - (pow2[a+b] + pow2[b+c] + pow2[c+d] + pow2[d+a] - pow2[a] - pow2[b] - pow2[c] - pow2[d] + 1)) % P
    U += 1
    addvalue(DX[x])
    
print(ans)


Measured memory_bytes: 122908
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b;
  cin >> a >> b;
  if(a>b)
    cout<<"a > b"<<endl;
  else if(a<b)
    cout<<"a < b"<<endl;
  else
    cout<<"a == b"<<endl;
}


Measured memory_bytes: 3068
#include <iostream>

using namespace std;

int main()
{
    int col[3]= {0},row[3]= {0},dig1[9]={0},dig2[9]={0};
    long long a[3][3],tam;
    for (int i=0; i<3; i++)
        for (int j=0; j<3; j++)
            cin >> a[i][j];
    int n;
    cin >> n;
    while (n--)
    {
        cin >> tam;
        for (int i=0; i<3; i++)
            for (int j=0; j<3; j++)
            {
                if (a[i][j]==tam)
                {
                    row[i]++;
                    col[j]++;
                    dig1[i-j+3]++;
                    dig2[i+j]++;
                    if (row[i]==3 || col[j]==3 || dig1[i-j+3]==3 || dig2[i+j]==3 )
                    {
                        cout <<"Yes";
                        return 0;
                    }
                }
            }
    }
    cout << "No";
}



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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;
const ll N= 1e6+55,mod = 1e9+7;
ll d[N],t[N];
map<ll,ll>m;
int main() {
// 	freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	ll i,j,n,mm,f=1;
	sc(n);
	for(i=1;i<=n;i++){
		sc(d[i]);
		m[d[i]]++;
	}
	sc(mm);
	for(i=1;i<=mm;i++){
		sc(t[i]);
		if(m[t[i]]){
			m[t[i]]--;	
		}
		else{
			f=0;
		}
	}
	if(f)
	printf("YES\n");
	else printf("NO\n");


}

Measured memory_bytes: 18432
<?php
fscanf(STDIN, "%d %d %d %d", $a, $b, $c, $d);

for($i = 1; $i <= 100; $i++){
 $c = $c - $b;
  
  if($c > 0){
    $a = $a - $d;
    
    if($a > 0){
    } else {
      echo "No";
      break;
    };
    
  } else {
    echo "Yes";
    break;
  };
}
?>

Measured memory_bytes: 16080
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



string s;

bool f(int x){
	if (2*x <= s.size()){
		return true;
	}
	char a = s[x-1];
	for (int p = x-1; p >= (int)s.size()-x; p--){
		if (a!=s[p])return false;
	}

	return true;
}


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

	cin>>s;

	int lb = 1, ub = s.size() + 1;
	while (ub-lb>1){
		int mid = (lb+ub)/2;
		if (f(mid))lb=mid;
		else ub=mid;
	}
	cout<<lb<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fin(ans) cout << ans << endl

int main(void) {
  long long int N, A, B;
  cin >> N >> A >> B;
  if ((B - A) % 2 == 0) {
    fin((B - A) / 2);
    return 0;
  } else {
    if (min(B-1, N-A) == B - 1) {
      fin(A + (B - A - 1) / 2);
      return 0;
    } else {
      fin(N - B + 1 + (B - A - 1) / 2);
      return 0;
    }
      
  }
  return 0;
}


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int D; cin >> D;
	
	if(D == 25) cout << "Christmas" << endl;
	else if(D == 24) cout << "Christmas Eve" << endl;
	else if(D == 23) cout << "Christmas Eve Eve" << endl;
	else if(D == 22) cout << "Christmas Eve Eve Eve" << endl;




	return 0;

}


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

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)
#define print(x) cout << x
#define println(x) cout << x << endl
#define printd(x, f) cout << fixed << setprecision(f) << x << endl

#define PB push_back
#define MP make_pair
#define F first
#define S second

#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PI acos(-1.0)

int main()
{
  string S; cin >> S;
  vll v(3, 0);
  REP(i, SIZE(S)) {
    if (S[i] == 'a') v[0]++;
    else if (S[i] == 'b') v[1]++;
    else v[2]++;
  }
  sort(ALL(v));
  if ((v[2] - v[0]) <= 1) println("YES");
  else println("NO");
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<map>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define cout(x) cout << x << endl;
// for (int i = 0; i < N; ++i) cin >> A[i];
typedef vector<int> vint;
typedef vector<long> vl;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef map<string, int> mapstri;
typedef map<string, int> mapii;

int main () {
    int N, M;
    cin >> N >> M;
    long long n_ue = 1;
    long long n_shita = 1;
    long long m_ue = 1;
    long long m_shita = 1;
    long long n_ans = 0;
    long long m_ans = 0;
    long long ans;
    if(N > 1) {
        for(int i = N -1; i < N+1; ++i) {
            n_ue *= i;          
        }
        n_ans = n_ue / 2;
    }
    if(M > 1) {
        for(int i = M -1; i < M+1; ++i) {
            m_ue *= i;
        }
        m_ans = m_ue / 2;
    } 
    ans = n_ans + m_ans;
    cout(ans);
    return 0;
}

Measured memory_bytes: 888
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;sc.hasNext();) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			String str = String.valueOf(a+b);
			System.out.println(str.length());
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

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

Measured memory_bytes: 12000
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
#include<iomanip>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  
  const double PI = acos(-1);
  int a,b,h,m;
  

  cin >> a >> b >> h >> m;

  double dc = h * 30 + m * 0.5;
  double dt = m * 6;

  double d = abs(dc - dt);
  if (d > 180) d = 360 - d;
  if (d == 180) {
    cout << a + b << endl;
    return 0;
  }
  double rad = d * (PI/180);

  double ans = a*a + b*b - 2*b*a*cos(rad);

  cout << fixed << setprecision(20) << sqrt(ans) << endl;
  return 0;
}


Measured memory_bytes: 3680
{-# LANGUAGE OverloadedStrings #-}
import Data.Maybe
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU

main = do
  n <- getInt
  s <- getLine
  putStrLn $ if n >= 3200 then s else "red"

-- IO
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getInt :: IO Int
getInt = readInt <$> BS.getLine

getIntList :: IO [Int]
getIntList = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

getIntVec :: Int -> IO (VU.Vector Int)
getIntVec n = VU.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

Measured memory_bytes: 380
direct = ((0, -1), (0, -2), (0, -3), (0, 1), (0, 2), (0, 3),
          (-1, 0), (-2, 0), (-3, 0), (1, 0), (2, 0), (3, 0))

def bomb(x, y, mp):
  mp[y][x] = "0"
  for dx, dy in direct:
    nx, ny = x + dx, y + dy
    if 0 <= nx <= 7 and 0 <= ny <= 7 and mp[ny][nx] == "1":
      bomb(nx, ny, mp)

n = int(input())

for i in range(n):
  input()
  mp = [list(input()) for _ in range(8)]
  x, y = int(input()) - 1, int(input()) - 1
  
  bomb(x, y, mp)

  print("Data " + str(i + 1) + ":")
  
  for line in mp:
    print("".join(map(str,line)))




Measured memory_bytes: 5624
S = list(input())
if(S[-1]=='s'):
  ans = ''
  for i in range(len(S)):
    ans += S[i]
  ans += 'e'
  ans += 's'
  print(ans)
else:
  ans = ''
  for i in range(len(S)):
    ans += S[i]
  ans += 's'
  print(ans)

Measured memory_bytes: 9132
import sys
import collections
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    s = [input() for _ in range(n)]
    cnt = collections.Counter(s)
    cnt_max = max(cnt.values())
    d = [k for k, v in cnt.items() if v == cnt_max]
    d = sorted(d)
    print(*d, sep='\n')

if __name__ == '__main__':
    main()

Measured memory_bytes: 35896
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;


int main(){

	int num,winner,rate,sum,winner_get,tmp;

	while(true){
		scanf("%d %d %d",&num,&winner,&rate);
		if(num == 0 && winner == 0 && rate == 0)break;

		sum = 0;

		for(int i = 1; i <= num; i++){
			scanf("%d",&tmp);
			sum += tmp;
			if(i == winner){
				winner_get = tmp;
			}
		}

		if(winner_get == 0){
			printf("0\n");
		}else{
			printf("%d\n",(sum*(100-rate))/winner_get);
		}
	}

	return 0;
}

Measured memory_bytes: 2692
#include<cstdio>
#include<iostream>
#define maxn 100005
#define ll long long 
using namespace std;
ll n,q,a[maxn],sum;
int tm[maxn];
int main(void)
{
	while(~scanf("%lld",&n))
	{
		sum=0;
		for(int i=0;i<n;++i)
		{
			scanf("%lld",&a[i]);
			sum+=a[i];
			tm[a[i]]++;
		}
		scanf("%lld",&q);
		ll b,c;
		for(int i=0;i<q;++i)
		{
			scanf("%lld %lld",&b,&c);
			sum+=(c-b)*tm[b];
			tm[c]+=tm[b];
			tm[b]=0;
			printf("%lld\n",sum);
		}
	}
	return 0;
}

Measured memory_bytes: 4368
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<utility>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<bitset>
using namespace std;

int main(){

    int n;
    cin >> n;
    int sum=0;
    int m=-1;
    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        sum += tmp;
        m = max(m,tmp);
    }
    sum -= m/2;
    cout << sum <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i,j,k,ans=1;
    int w,h,x,y,judge;
    double s=0.0;


    scanf("%d %d %d %d",&w,&h,&x,&y);

    s = (double)w*(double)h/2.0;

    judge=0;
//        if((w%2==0)&&(h%2==0)){
            // if((2*x==w)&&(2*y==h)){
            //     judge=1;
            // }   
//        }

	if( !(w==0||h==0) ){
//        printf("ok.\n");
  	if((w%2==0)&&(h%2==0)){
//          printf("ok.\n");
            if((w/2==x)&&(h/2==y)){
//                printf("ok.\n");
                judge=1;
            }   
        }
    }

    printf("%lf %d\n",s,judge);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>

using namespace std;

string solve(int sx, int sy, int tx, int ty){
    string str = "";

    int diff_x = tx - sx;
    int diff_y = ty - sy;
    for(int i=1;i<=diff_y;i++)
        str.push_back('U');
    for(int i=1;i<=diff_x;i++)
        str.push_back('R');

    for(int i=1;i<=diff_y;i++)
        str.push_back('D');
    for(int i=1;i<=diff_x;i++)
        str.push_back('L');

    
    str.push_back('L');
    for(int i=1;i<=diff_y+1;i++){
        str.push_back('U');
    }
    for(int i=1;i<=diff_x+1;i++){
        str.push_back('R');
    }
    str.push_back('D');
    str.push_back('R');
    for(int i=1;i<=diff_y+1;i++){
        str.push_back('D');
    }
    for(int i=1;i<=diff_x+1;i++){
        str.push_back('L');
    }
    str.push_back('U');

    return str;
}

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    cout << solve(sx, sy, tx,ty) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
       
 
int main() {
  ll n,a,b;
  ll ans=0;
  ll remain=100000000;
  cin >>n >>a >>b;
  if(n>=a+b){ll q=n/(a+b);
             remain=min(n-(a+b)*q,a);
             ans=q*a+remain;
             cout << ans  << endl;}
  else{if(n>=a){
             cout << a << endl;}else{cout << n << endl;}
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int n,m,a,b,dp[111111],ans;
vector<int>v[111111];
int dfs(int x){
	if(dp[x])return dp[x];
	rep(i,v[x].size())dp[x]=max(dfs(v[x][i])+1,dp[x]);
	return dp[x];
}
signed main(){
	cin>>n>>m;
	rep(i,m){
		cin>>a>>b;
		a--,b--;
		v[a].push_back(b);
	}
	rep(i,n)if(!dp[i])dfs(i);
	rep(i,n)ans=max(ans,dp[i]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
using namespace std;
int main()
{
	ll x, rez = 0;
	cin>>x;
	while(x >= 500){
		x -= 500;
		rez += 1000;
	}
	while(x >= 5){
		x -= 5;
		rez += 5;
	}
	cout<<rez<<endl;
	return 0;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<queue>
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-6;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<char,char> pcc;
const ll mod=998244353;
int a[1004];
int main()
{
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		if(i%3!=0&&i%5!=0)
		ans+=i;
	}
	cout<<ans<<endl;
}

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

int main() {
  int H,N;
  cin >> H >> N;
  int sum = 0;
  
  vector<int>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    sum += A.at(i);
  }
  if (sum >= H){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3732
#include <iostream> 
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cassert>
#include <cctype>
#include <climits>

using namespace std;

using ll = long long int;
using vi = vector<ll>;


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

	vi p(n), c(n);
	for (int i = 0; i < n; ++i) { cin >> p[i]; --p[i]; }
	for (int i = 0; i < n; ++i) cin >> c[i];

	ll mejorRes = - (1000LL * 1000LL * 1001LL);

	for (int i = 0; i < n; ++i) {
		//Empezamos en la casilla i
		ll sumaAct = 0;
		ll longPerm = 0;
		int idx = i;
		bool prim = true;

		while (prim || idx != i && longPerm < k) {
			prim = false;
			sumaAct += c[p[idx]];
			idx = p[idx];
			++longPerm;
			mejorRes = max(mejorRes, sumaAct);
		}

		//Una vez que llegamos aquí o bien hemos acabado el ciclo o nos hemos quedado sin movimientos
		if (longPerm == k) continue;
		else {
			if (sumaAct <= 0) continue;
			else {
				assert(k / longPerm != 0);
				sumaAct = sumaAct * ((k / longPerm) - 1);
				ll nuevak = (k % longPerm) + longPerm;
				
				longPerm = 0;
				while (longPerm < nuevak) {
					sumaAct += c[p[idx]];
					idx = p[idx];
					++longPerm;
					mejorRes = max(mejorRes, sumaAct);
				}
			}
		}
		

	}
	cout << mejorRes << '\n';

	return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int n;
  for(;;) {
    cin >> n;
    if(n == 0) break;
    int p, d1, d2, num, dis = 0;
    for(int i=0; i<n; ++i) {
      cin >> p >> d1 >> d2;
      if(max(dis, d1 + d2) == d1 + d2) {
        num = p;
        dis = d1 + d2;
      }
    }
    cout << num << " " << dis << endl;
  }
}




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

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

using namespace std;

int main()
{
	int n, ans=0;
	vector<int> nums;
	int slot[5];
	cin >> n;
	for(int i=2; i<=n; i++){
		bool prime=true;
		int num=0;
		for(int j=2; j<=sqrt(i); j++){
			if (i % j == 0){
				prime = false;
				break;
			}
		}
		if (prime == false) continue;
		for(int j=i; j<=n; j=j*i){
			num += n/j;
		}
		nums.push_back(num);
	}
	//スロットの初期化
	rep(i, 5){
		slot[i] = 0;
	}
	//スロットの構成
	rep(i, nums.size()){
		if(nums[i] >= 74) slot[0]++;
		if(nums[i] >= 24) slot[1]++;
		if(nums[i] >= 14) slot[2]++;
		if(nums[i] >= 4) slot[3]++;
		if(nums[i] >= 2) slot[4]++;
	}
	//74パターン
	ans += slot[0];
	//24, 2パターン
	ans += slot[1]*(slot[4]-1);
	//14, 4パターン
	ans += slot[2]*(slot[3]-1);
	//4, 2, 2パターン
	ans += slot[3]*(slot[3]-1)/2 * (slot[4]-2);
	cout << ans << endl;
	return 0;
}

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

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


int main(){
    long X;cin>>X;
    long cnt=1;
    while(X-cnt>0){
    	X-=cnt;
    	cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::io::BufRead;

fn main() {
    let stdin = io::stdin();
    for line in stdin.lock().lines() {
        let v: Vec<usize> = line.unwrap()
            .split_whitespace()
            .map(|s| s.parse().unwrap())
            .collect();
        if v == [0, 0] {
            return;
        }
        let rect = ("#".repeat(v[1]) + "\n").repeat(v[0]);
        println!("{}", rect);
    }
}



Measured memory_bytes: 5056
n,k=map(int,input().split())
a=[]
b=[]
c=[0 for i in range(n)]
for i in range(k):
    b.append(int(input()))
    a.append(list(map(int,input().split())))
for i in range(k):
    for j in range(b[i]):
        c[a[i][j]-1]+=1
count=0
for i in range(n):
    if c[i]==0:
        count+=1
print(count)

Measured memory_bytes: 9148
#include<cstdio>
using namespace std;
int main(){
    int n,v[20],c[20],ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&v[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%d",&c[i]);
        if(v[i]>c[i]){
            ans+=v[i]-c[i];
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cstring>
    #include <string>
    #include <stack>
    #include <queue>
    #include <vector>
    #include <set>
    #include <cmath>
    #include <cstdlib>
    #define FOR(i,a,b) for(int i=a;i<b;i++)
    #define MA(i,j) make_pair(i,j)
    #define PA pair<int,int>
    #define PB push_back
    #define PQ priority_queue<int>
    #define PGQ priority_queue<int,vector<int>,greater<int> >
    #define VE vector<int>
    #define VP vector<PA>
    #define YES(i) cout<<(i?"YES":"NO")<<endl
    #define Yes(i) cout<<(i?"Yes":"No")<<endl
    #define MOD 1000000007
    #define INF 1000000007
    #define PI 3.14159265358979323846
    using namespace std;
    //
    int N,A,B;
    vector<long long> H;
    bool check(long long X){
      long long cnt=0;
      FOR(i,0,N){
        long long G=H[i]-B*X;
        if(G<=0){
          return true;
        }else{
          cnt+=(G+(A-B)-1)/(A-B);
        }
        if(cnt>X){
          return false;
        }
      }
      return true;
    }
    int main(){
      cin>>N>>A>>B;
      FOR(i,0,N){
        int h;
        cin>>h;
        H.PB(h);
      }
      sort(H.rbegin(),H.rend());
      long long lo=0,up=1LL<<30;
      while(up-lo>1){
        long long md=(lo+up)/2;
        if(check(md)){
          up=md;
        }else{
          lo=md;
        }
      }
      cout<<up<<endl;
      return 0;
    }

Measured memory_bytes: 1400
#include<iostream>

using namespace std;

int main(){

	int N,max=1,min=1;
	long long c=0;

	while(1){

		cin>>N;

		if(N==0) break;

		max=1,min=1;
		c=0;
		while(min<=max){
			int num=(max+min)*(max-min+1)*1/2;
			if(num==N) c++,min++,max++;
			else if(num<N) max++;
			else min++;
		}
		c--;

		cout<<c<<endl;
	}
}

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

string s;

int main() {
  	cin >> s;
  	if (s == "SUN")
  		cout << 7 << '\n';
    if (s == "MON")
      	cout << 6 << '\n';
  	if (s == "TUE")
      	cout << 5 << '\n';
    if (s == "WED")
    	cout << 4 << '\n';
    if (s == "THU")
      	cout << 3 << '\n';
    if (s == "FRI")
      	cout << 2 << '\n';
    if (s == "SAT")
      	cout << 1 << '\n';
 	return 0; 
}

Measured memory_bytes: 256
import java .util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);int a = sc.nextInt();
		int b = sc.nextInt();
		long c=0;
		if(a==1)
		c=c+300000;
			if(a==2)
		c=c+200000;
			if(a==3)
		c=c+100000;
			if(b==1)
		c=c+300000;
			if(b==2)
		c=c+200000;
			if(b==3)
		c=c+100000;
		if(a==1&&b==1)
		c=c+400000;
System.out.println(c);	}
}

Measured memory_bytes: 23892
#include <stdio.h>

int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }

    int min = a[0],max = a[0];
    long long sum;
    for(int i = 0; i < n; i++){
        if(a[i] < min){
            min = a[i];
        }
        if(a[i] > max){
            max = a[i];
        }
        sum += a[i];
    }

    printf("%d %d %lld\n",min,max,sum);

    return 0;
}


Measured memory_bytes: 2784
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

struct DATA{
  int n;
  bool l, c;
  DATA(){ n=0; l=false; c=false; }
};

int n;
vector< vector<DATA> > data;

int solve(){
  int min_, max_;
  for(int i=0; i<n; ++i){
    min_ = data[i][0].n;
    for(int j=0; j<n; ++j) min_ = min(min_, data[i][j].n);
    for(int j=0; j<n; ++j){
      if(data[i][j].n == min_) data[i][j].l = true;
    }
  }
  for(int i=0; i<n; ++i){
    max_ = data[0][i].n;
    for(int j=0; j<n; ++j) max_ = max(max_, data[j][i].n);
    for(int j=0; j<n; ++j){
      if(data[j][i].n == max_) data[j][i].c = true;
    }
  }
  for(int i=0; i<n; ++i){
    for(int j=0; j<n; ++j){
      if(data[i][j].l && data[i][j].c) return data[i][j].n; 
    }
  }
  return 0;
}

int main(){
  while(1){
    cin >> n;
    if(!n) break;
    data = vector< vector<DATA> >(n, vector<DATA>(n, DATA()));
    for(int i=0; i<n; ++i){
      for(int j=0; j<n; ++j) cin >> data[i][j].n;
    }
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
 
class Program
{
    static void Main()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
 
 
    void Solve()
    {
       int X = cin.Nextint;
       long Y = 0;
       for (int i = 0; i <= X; i++)
       {
       	 Y+= i;
       	 if(Y >= X)
       	 {
       	 	WriteLine(i);
       	 	break;
       	 }
       }
    }
 
}
 
class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 11216
class DoublyLinkedList:
    def __init__(self):
        self.nil = self.make_node(None)
        self.nil['next'] = self.nil
        self.nil['prev'] = self.nil
    def make_node(self, k):
        return {'key':k, 'next':None,'prev':None}

    def insert(self, key):
        x = self.make_node(key)
        x['next'] = self.nil['next']
        self.nil['next']['prev'] = x
        self.nil['next'] = x
        x['prev'] = self.nil

    def listSearch(self,key):
        cur = self.nil['next']
        while cur['key'] != None and cur['key'] != key:
            cur = cur['next']
        return cur

    def delete(self, k):
        self.delete_node(self.listSearch(k))

    def delete_node(self,x):
        if x['key'] == None: return
        x['prev']['next'] = x['next']
        x['next']['prev'] = x['prev']

    def deleteFirst(self):
        self.delete_node(self.nil['next'])

    def deleteLast(self):
        self.delete_node(self.nil['prev'])

    def printList(self):
        x = self.nil['next']
        while True:
            if x['key'] == None:
                break
            else:
                print x['key'],
                x = x['next']
        print

def main():
    N = int(raw_input())
    commands = []
    for i in xrange(N):
        commands.append(raw_input())
    d = DoublyLinkedList()
    for c in commands:
        a = c[0]
        if a == 'i':
            d.insert(int(c[7:]))
        else:
            if c[6] == 'F':
                d.deleteFirst()
            elif c[6] == 'L':
                d.deleteLast()
            else:
                d.delete(int(c[7:]))

    d.printList()
    return 0

main()

Measured memory_bytes: 439092
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, a, sum[100008];

int main(){
	cin >> n;
	memset(sum, 0, sizeof(sum));
	for(ll i = 1; i <= n; i++){
		cin >> a;
		sum[a-1]++;
		sum[a]++;
		sum[a+1]++;
	}
	
	ll ans = 0;
	for(ll i = 1; i <= 100000; i++){ans = max(sum[i], ans);}
		
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int num=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') {num=num*10+ch-'0'; ch=getchar();}
	return num*f;
}
int main()
{
	int n=read();int Bit=0;
	for(int i=1;i<=n;i++)
	{
		int x=read(),y=read();
		if(x==y) Bit++;else Bit=0;
		if(Bit==3) {
			puts("Yes"); return 0;
		}
		
	}
	puts("No");
	return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;


int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n)   cin >> a[i];

    set<int> edge[n];
    rep(i, n){
        edge[i].insert(a[i]-1);
    }

    int cnt = 0;

    rep(i, n){
        for(auto to : edge[i]){
            if(0 < edge[to].count(i)){
                cnt++;
            }
        }
    }

    cout << cnt/2 << endl;

    return 0;
}

Measured memory_bytes: 10112
// luogu-judger-enable-o2
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 200005
#define M 200005
#define mid ((l+r)/2)
#define ls 2*rt
#define rs 2*rt+1
int head[M];
int cnt;
struct edge{ int des,next; }e[N];

void ins(int u,int v){ e[++cnt].des=v;  e[cnt].next=head[u];  head[u]=cnt; }


int n,m;
// 人数+r -( m+1 +l ) 
struct node{
	int l,r;
}a[N];

bool cmp(node a,node b){ return a.l<b.l; }

int maxn[M<<2],lazy[M<<2];

void pushup(int rt){ maxn[rt]=max(maxn[ls],maxn[rs]); }

void build(int rt,int l,int r){
	if(l==r){ maxn[rt]=l; return; }
	build(ls,l,mid);
	build(rs,mid+1,r);
	pushup(rt);
}


void pushdown(int rt){
	int t=lazy[rt];  lazy[rt]=0;
	lazy[ls]+=t;   lazy[rs]+=t;
	maxn[ls]+=t;   maxn[rs]+=t;
}

void update(int rt,int l,int r,int ll,int rr){
	if(l>=ll&&r<=rr){
		maxn[rt]+=1;
		lazy[rt]+=1;
		return;
	}
	if(lazy[rt])    pushdown(rt);
	if(ll<=mid)     update(ls,l,mid,ll,rr);
	if(rr>=mid+1)   update(rs,mid+1,r,ll,rr);
	pushup(rt);
}

int query(int rt,int l,int r,int ll,int rr){
	if(l>=ll&&r<=rr) return maxn[rt];
	int res=0;
	if(lazy[rt])   pushdown(rt);
	if(ll<=mid)    res=max(res,query(ls,l,mid,ll,rr));
	if(rr>=mid+1)  res=max(res,query(rs,mid+1,r,ll,rr));
	return res;
}


int main(){
	int ans=0;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i){
		scanf("%d %d",&a[i].l,&a[i].r);
		ins(a[i].l,a[i].r);
	}
	sort(a+1,a+1+n,cmp);
	build(1,0,m+1);
	for(int i=0;i<=m;++i){
		for(int j=head[i];j;j=e[j].next){
			int r=e[j].des;
			update(1,0,m+1,1,r);
		}
		ans=max(ans,query(1,0,m+1,i+1,m+1)-(m+i+1));
	}
	ans=max(ans,n-m);
	printf("%d\n",ans);
	return 0;
}
























Measured memory_bytes: 10368
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Stack<Integer> stack = new Stack<>();
        int count = 0;
        for(int i = 0; i < s.length(); i++) {
            int num = s.charAt(i) - '0';
            if(!stack.isEmpty() && stack.peek() != num) {
                count += 2;
                stack.pop();
            } else {
                stack.push(num);
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 28956
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.
	string s;
	cin >> s;
	for (LL i = 0; i < s.length(); i += 2) {
		cout << s[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 592
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main(){
    ll n,m;
    cin >> n >> m;
    vector<string> a(n),b(m);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,m){
        cin >> b[i];
    }
    for(ll i=0;i+m-1<n;i++){
        for(ll j=0;j+m-1<n;j++){
            bool ok=true;
            rep(p,m){
                rep(q,m){
                    if(a[i+p][j+q]!=b[p][q]) ok=false;
                }
            }
            if(ok){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const int INF = 1e9 + 7;
int h[MAXN];
int dp[MAXN]; 
int N,K;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> K;
	for (int i = 0; i < N; ++i) cin >> h[i];
	fill(dp, dp + MAXN, INF);
	dp[0] = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i+1; j < N && j-i <= K; ++j) {
			dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
		}
	}
	cout << dp[N - 1] << '\n';
	return 0;
}

Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)

void vprn(vector<int> &v){ for(int i=0;i<v.size();i++) cout<<v[i]<<(i<v.size()-1?",\t":"\n"); }

vvi solve(int H, int W, int N, vi &A){

	vi AA(H*W);
	int j = 0;
	rp(c, 0, N){
		int n = A[c];//n:number of color
		rp(i, 0, n){
			AA[j] = c+1;
			j++;
		}
	}

	// printf("H %d W %d N %d\n",H,W,N);//
	// vprn(A);//
	// vprn(AA);//

	vvi V(H, vi(W));
	rp(i, 0, H*W){
		int h = i/W;
		int w = i%W;
		if(h%2) w = W - 1 - w;
		// printf("%d %d %d %d\n",h,w,i, AA[i]);//
		V[h][w] = AA[i];
	}
	return V;
}

int main(){
	int H,W,N; cin>>H>>W>>N;
	vi A(N); rp(i, 0, N) cin>>A[i];
	vvi V = solve(H, W, N, A);
	rp(i, 0, H){
		rp(j, 0, W){
			printf("%d%c",V[i][j],j+1==W?'\n':' ');
		}
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  cout << s[0] << s.size() - 2 << s.back() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <string>
using namespace std;
#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 ll long long

int main() {
    //入力
    ll k,x,d;
    cin >> x >> k >> d;
    x = abs(x);

    ll ans = 0;
    ll a1 = x / d;
    ll a2;
    if (a1 * d == x)
        a2 = a1-1;
    else
        a2 = a1 + 1;
    if (k <= a1) {
        ans = x - k * d;
    }
    else {
        if (k % 2 == 0) {
            //kが偶数
            if (a1 % 2 == 0) {
                ans = x - a1 * d;
            }
            else {
                ans = x - a2 * d;
            }
        }
        else {
            //奇数
            if (a1 % 2 == 0) {
                ans = x - a2 * d;
            }
            else {
                ans = x - a1 * d;
            }
        }
    }

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


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

int main()
{
 
  
     int n;
     cin>>n;
     int a=0,w=0,t=0,r=0;
     while(n--)
     {
       string s;
       cin>>s;
       if(s=="WA")
        w+=1;
      if(s=="AC")
        a+=1;
      if(s=="TLE")
        t+=1;
      if(s=="RE")
        r+=1;
     }
     cout<<"AC"<<" "<<"x"<<" "<<a<<endl;
     cout<<"WA"<<" "<<"x"<<" "<<w<<endl;
     cout<<"TLE"<<" "<<"x"<<" "<<t<<endl;
     cout<<"RE"<<" "<<"x"<<" "<<r<<endl;

      
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    string s; cin >> s;
    // even = '0', odd = '1'
    ll min_color = s.size();
    ll count = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (i % 2 == 0 && s[i] != '0') count++;
        if (i % 2 == 1 && s[i] != '1') count++;
    }
    min_color = min(min_color, count);
    count = 0;
    // even = '1', odd = '0'
    for (int i = 0; i < s.size(); ++i) {
        if (i % 2 == 0 && s[i] != '1') count++;
        if (i % 2 == 1 && s[i] != '0') count++;
    }
    min_color = min(min_color, count);
    cout << min_color << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	printf("%d %d %d",a,b,c);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int f=0;
  for(int i=0;s[i];++i)
  {
    if(s[i]-'7'==0)
      f=1;
  }
  if(f)
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 3628
#include<iostream>
#include<map>

using namespace std;

int main(void) {
	int N;
	map<int, int> cardCnt;

	cin >> N;

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

	int twoCnt = 0;
	int ans = 0;

	for (auto itr = cardCnt.begin(); itr != cardCnt.end(); itr++) {
		ans++;
		//cout << itr->first << " " << itr->second << endl;
		if (itr->second % 2 == 0) {
			twoCnt++;
		}
	}
	if (twoCnt % 2 == 1) ans--;

	cout << ans << endl;
	system("pause");
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    int64_t res = 0;
    rep(i,n+1){
        if(i%3!=0 && i%5!=0){
            res += i;
        }
    }
    cout <<res << endl;
}

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

int64_t nextSnuke(int64_t n) {
    if(n <= 9)
        return n;

    int64_t best_num = 0;
    int64_t best_denom = -1;
    
    vector<int> d;
    int64_t aux = n;

    while(aux > 0) {
        d.push_back(aux % 10);
        aux /= 10;
    }

    int sz = d.size();

    for(int i = 0; i < sz; ++i) {
        vector<int> t = d;
        for(int j = 0; j <= i; ++j)
            t[j] = 9;
        int64_t num = 0;
        int64_t denom = 0;

        for(int j = sz - 1; j >= 0; --j) {
            num = 10LL * num + t[j];
            denom += t[j];
        }
         
        if(best_denom == -1 or best_num * denom > num * best_denom) {
            best_denom = denom;
            best_num = num;
        }
    }
    
    return best_num;
}

int main() {
    int k; cin >> k;
    
    int64_t temp = 1;
    for(int i = 0; i < k; i += 1) {
        cout << temp << "\n";
        temp = nextSnuke(temp + 1);
    }
}

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

int main() {
	int n;
	while(cin >> n && n != 0) {
		vector<string> s(n);
		for(int i=0;i<n;i++) cin >> s[i];
		int lc = 0, rc = 0, ans = 0;
		for(int i=0;i<n-1;i++) {
			if(s[i]=="lu" and s[i+1]=="ru") {
				ans++;
			}else if(s[i]=="ru" and s[i+1]=="lu") {
				ans++;
			}else if(s[i]=="ld" and s[i+1]=="rd") {
				ans++;
			}else if(s[i]=="rd" and s[i+1]=="ld") {
				ans++;
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3140
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <stack>
#include <queue>
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if(a < 10 && b < 10) {
    cout << a*b << endl;
  }
  else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
d = {}
for i in range(26):
    c = chr(i+ord('a'))
    d[c] = 10**18

for i in range(n):
    s = str(input())
    de = {}
    for i in range(26):
        c = chr(i+ord('a'))
        de[c] = 0
    for j in range(len(s)):
        if s[j] not in de:
            de[s[j]] = 1
        else:
            de[s[j]] += 1
    for k, v in de.items():
        d[k] = min(d[k], de[k])

d = sorted(d.items())
#print(d)
ans = ''
for k, v in d:
    ans += k*v
print(ans)


Measured memory_bytes: 3064