akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

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

const int mod = 1000000007;
long v[100];

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

  int n;
  cin >> n;

  for(int i = 2; i <= n; i++) {
    int i_ = i;
    for(int j = 2; j <= n; j++) {
      while(i_%j==0) {
        v[j]++;
        i_/=j;
      }
    }
  }

  int over2cnt = 0;
  int over4cnt = 0;
  int over14cnt = 0;
  int over24cnt = 0;
  int over74cnt = 0;
  rep(i, n+1) {
    if(v[i] >= 2) {
      over2cnt++;
    }
    if(v[i] >= 4) {
      over4cnt++;
    }
    if(v[i] >= 14) {
      over14cnt++;
    }
    if(v[i] >= 24) {
      over24cnt++;
    }
    if(v[i] >= 74) {
      over74cnt++;
    }
  }
  
  long res = 0;

  if(over4cnt >= 2) {
    res += (over4cnt * (over4cnt-1)) / 2 * (over2cnt-2);
    res += over14cnt * (over4cnt-1);
    res += over24cnt * (over2cnt-1);
    res += over74cnt;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 
    int n;
    cin>>n;
  	string str;
  	cin>>str;
  	if(str.length()<=n)cout<<str;
  	else {
  		for(int i=0;i<n;i++){
  			cout<<str[i];
		}
		cout<<"...";
	}
    return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 998244353;

ll dp[310][310];

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


	string S;
	int K;
	int k = 0;
	int A[301] = {};

	cin >> S >> K;
	rep(i, S.size()) {
		if (S[i] == '0') k++;
		else A[k]++;
	}

	int kosuu = 0;
	dp[0][0] = 1;
	for (int i = k; i >= 0; i--) {
		if (i % 3 == 0) {
			for (int j = kosuu; j >= 0; j--) {
				ll tmp = 0;
				for (int k = kosuu; k >= 0; k--) {
					dp[j][k] %= mod;
					tmp += dp[j][k];
					rep1(p, A[i]) dp[j + p][k + p] += dp[j][k];
					dp[j][k] = tmp;
				}
			}
		}
		else {
			for (int j = kosuu; j >= 0; j--) {
				ll tmp = 0;
				for (int k = kosuu; k >= 0; k--) {
					tmp += dp[j][k];
					rep1(p, A[i]) dp[j + p][k + p] += dp[j][k];
					dp[j][k] = tmp;
				}
			}
		}
		kosuu += A[i];
	}

	ll kotae = 0;
	rep(i, min(K, kosuu) + 1) {
		kotae += dp[i][0] % mod;
	}
	co(kotae % mod);



	Would you please return 0;
}

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

using namespace std;

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

int mp[12][12];

void dfs_fill(int y, int x)
{
	if (y < 0 || y >= 12 || x < 0 || x >= 12) return;

	if (!mp[y][x]) return;

	mp[y][x] = 0;

	for (int i = 0; i < 4; ++i) dfs_fill(y + dy[i], x + dx[i]);
}

int main()
{
	string s;
	while (getline(cin, s)) {
		if (s.empty()) continue;

		for (int y = 0; y < 12; ++y) {
			for (int x = 0; x < 12; ++x) mp[y][x] = s[x] - '0';
			getline(cin, s);
		}

		int ans = 0;

		for (int i = 0; i < 12; ++i) for (int j = 0; j < 12; ++j) {
			if (mp[i][j]) {
				dfs_fill(i, j);
				ans++;
			}
		}

		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1184
#include<cstdio>
using namespace std;
char s[20];
int main(){
	scanf("%s",s+1);
	for (int i=1;s[i];i++){
		if((i&1)&&s[i]!='h'){puts("No");return 0;}
		if(!(i&1)&&s[i]!='i'){puts("No");return 0;}
		if(s[i]=='h'&&!s[i+1]){puts("No");return 0;}
	}
	puts("Yes");return 0;
}

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

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if (m1 != m2) cout << 1 << endl;
  else cout << 0 << endl;
}


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

template<typename T>
T get_value(std::istream& is);

int main() {
  cin.sync_with_stdio(false);
  cin.tie(nullptr);

  const auto A {get_value<int>(cin)}, B {get_value<int>(cin)};

  auto res {0u};
  for (auto i {A}; i <= B; ++i) {
    const auto s {to_string(i)};
    res += equal(s.begin(), s.end(), s.rbegin());
  }

  cout << res << '\n';

  return 0;
}

template<typename T>
inline T get_value(std::istream& is)
{
  T v;
  is >> v;
  return v;
}


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

using namespace std;
int main() {
  long int N;
  cin >> N;
  long int count=0;
  long int K;
  for (long int i=1;i<=N;i++){
    K=N/i;
    count+=i*K*(K+1)/2;
  }
  cout << count <<endl;
return 0;
}

Measured memory_bytes: 3612
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#define INF 1000
using namespace std;

struct edge{int to,cap,rev;};

vector<edge> g[310];
bool used[310];

void add_edge(int from, int to, int cap){
    g[from].push_back((edge){to,cap,(int)g[to].size()});
    g[to].push_back((edge){from,0,(int)g[from].size()-1});
}

int dfs(int v,int t,int f){
    if(v==t){
        return f;
    }
    used[v]=true;
    for(int i=0;i<g[v].size();i++){
        edge &e=g[v][i];
        if(!used[e.to]&&e.cap>0){
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                g[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s,int t){
    int flow=0;
    for(;;){
        memset(used,0,sizeof(used));
        int f=dfs(s,t,INF);
        if(f==0) return flow;
        flow+=f;
    }
}
int main(){
    int h,w,m,c,nw,nc,nm,a,b;
    scanf("%d %d %d %d %d %d %d",&h,&w,&c,&m,&nw,&nc,&nm);
    while(h>=0||w>=0||c>=0||m>=0||nc>=0||nw>=0&&nm>=0){
        for(int i=0;i<310;i++){
            g[i].clear();
        }
        for(int i=1;i<=h;i++){
            add_edge(0,i,1);
            add_edge(i,101,1);
        }
        for(int i=51;i<=50+w;i++){
            add_edge(i,i+51,1);
            add_edge(i+51,203,1);
        }
        add_edge(101,152,nw);
        for(int i=153;i<=152+c;i++){
            add_edge(152,i,1);
            add_edge(i,i+51,1);
            add_edge(i+51,305,1);
        }
        add_edge(203,254,nc);
        for(int i=255;i<=254+m;i++){
            add_edge(254,i,1);
            add_edge(i,306,1);
        }
        add_edge(305,306,nm);
        for(int i=0;i<w;i++){
            scanf("%d",&a);
            for(int j=0;j<a;j++){
                scanf("%d",&b);
                add_edge(b,51+i,1);
            }
        }
        for(int i=0;i<c;i++){
            scanf("%d",&a);
            for(int j=0;j<a;j++){
                scanf("%d",&b);
                add_edge(101+b,153+i,1);
            }
        }
        for(int i=0;i<m;i++){
            scanf("%d",&a);
            for(int j=0;j<a;j++){
                scanf("%d",&b);
                add_edge(b+203,255+i,1);
            }
        }
        printf("%d\n",max_flow(0,306));
        scanf("%d %d %d %d %d %d %d",&h,&w,&c,&m,&nw,&nc,&nm);
    }
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int K,S;
    cin >> K >> S;
    ll cnt = 0;
    rep(x,K+1){
        rep(y,K+1){
            int z = S - x - y;
            if(z >= 0 && z <= K) cnt++; 
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<set>

using namespace std;

int main(void) {

    int N;
    int d[100] = {0};

    cin >> N;
    for (int i = 0; i < N; i++) cin >> d[i];

    set<int> values;
    for (int i = 0; i < N; i++) {
        values.insert(d[i]);
    }

    cout << values.size() << endl;

}


Measured memory_bytes: 256
import sys
from operator import ixor
from functools import reduce


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    s = reduce(ixor, a)
    res = [s ^ a[i] for i in range(n)]
    print(*res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 28628
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
long long func(long long x,long long y){
  long long r;
  long long x1 = x,y1 = y;
  if(x <= y){
    r = x;
    x = y;
    y = r;
  }
  r = y;
  while(x % y != 0){
    r = x;
    x = y;
    y = r % x;
  }
  //cout << x1 << " "<< y1 << " " << y << endl;
  return x1 / y * y1;
}

int main(){
  int n;
  cin >> n;
  long long x;
  vector<long long> vec;
  for(int i=0;i<n;i++){
    cin >> x;
    vec.push_back(x);
  }
  x = vec[0];
  for(int i=1;i<n;i++){
    x = func(x,vec[i]);
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
import copy
def check(y,x):
    if 0<=y<=h-1 and 0<=x<=w-1:
        return True
    return False

h,w,n=map(int,raw_input().split())
g=[[] for _ in xrange(h)]
for i in xrange(h):
    r=raw_input()
    for j in xrange(w):
        if r[j]=="S":
             sy,sx=i,j
        g[i].append(r[j])
d=[[0]*w for i in xrange(h)]
d1=copy.deepcopy(d)
visited=[[0]*w for i in xrange(h)]
visited1=copy.deepcopy(visited)
dx=[1,0,-1,0]
dy=[0,1,0,-1]
q=deque([[sy,sx]])
ans=0
for i in xrange(1,n+1):
    f=0
    while len(q)!=0:
        y,x=q.popleft()
        visited1[y][x]=2
        for j in xrange(4):
            nexty=y+dy[j]
            nextx=x+dx[j]
            if not check(nexty,nextx):continue
            if g[nexty][nextx]!="X" and visited1[nexty][nextx]==0:
                q.append([nexty,nextx])
                d1[nexty][nextx]=d1[y][x]+1
                visited1[nexty][nextx]=1
                if g[nexty][nextx]==str(i):
                    ans+=d1[nexty][nextx]
                    q=deque([[nexty,nextx]])
                    visited1=copy.deepcopy(visited)
                    d1=copy.deepcopy(d)
                    f=1
                    break
        if f==1:break
print(ans)

Measured memory_bytes: 63596
import sys
n=1000000
pr=[1]*n
pr[0],pr[1]=0,0
for i in range(2,int(n**0.5)+1):
    if pr[i]==1:
        for j in range(i**2,n,i):
            pr[j]=0
for i in range(2,n):
    pr[i]+=pr[i-1]
for line in sys.stdin:
    print pr[int(line)]

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

int main(){
ll k,n;
cin>>k>>n;
vector<ll> a(n);
for(ll i=0;i<n;i++){
    cin>>a[i];
}
ll m=INT_MAX;
ll s=0;
for(ll i=0;i<n;i++){
   if(i==0)
 s=a[n-1]-a[0];
   else
    s=abs(a[i-1]+(k-a[i]));

   if(s<m){
    m=s;
   }
        }
        cout<<m<<endl;
}



Measured memory_bytes: 1792
using AtCoderBeginnerContest143.Questions;
using AtCoderBeginnerContest143.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest143.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var ab = inputStream.ReadIntArray();
            var a = ab[0];
            var b = ab[1];
            yield return Math.Max(a - 2 * b, 0);
        }
    }
}


namespace AtCoderBeginnerContest143
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest143.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest143.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
//        long startTime = System.currentTimeMillis();
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] d = new int[N];
        for (int i = 0; i < N; i++) {
            d[i] = scanner.nextInt();
        }
        scanner.close();

        int sum = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                sum += d[i] * d[j];
            }
        }

        System.out.println(sum);

    }

}


Measured memory_bytes: 21972
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int A, B;
int W, H;

void createB(vvb &F) {
	REP(w, W) {
		REP(h, H / 2) {
			if (A) {
				if (h != H/2 - 1 && h % 2 && w % 2) {
					F[h][w] = false;
					A--;
				}
			}
			else {
				return;
			}
		}
	}
}

void createW(vvb &F) {
	REP(w, W) {
		FOR(h, H / 2, H) {
			if (B) {
				if (h % 2 && w % 2) {
					F[h][w] = true;
					B--;
				}
			}
			else {
				return;
			}
		}
	}
}

void draw(const vvb &F) {
	REP(w, W) {
		REP(h, H) {
			cout << (F[w][h] ? "#" : ".");

		}
		cout << "\n";
	}
}

int main() {
	cin >> A >> B;
	W = H = 100;
	A--; B--;
	vvb F;
	assign2d(F, 100, 100, false);

	REP(w, W) {
		REP(h, H / 2) {
			F[h][w] = true;
		}
	}
	createB(F);
	createW(F);
	cout << "100 100" << endl;
	draw(F);
	return 0;
}

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

int main(){
  int a,b,c,d,e;
  
  cin >> a >> b >> c >> d >> e;
  
 int ans = a*d+b*e;
  	for (int i=0;i<=max(d,e);i++){
      
    	ans = min (ans,a*max(0,(d-i))+b*max(0,(e-i))+c*2*i);
    }
  
  	cout << ans << endl;
}
 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007LL;

int main() {
	int A[3];
	for (int i = 0; i < 3; i++) cin >> A[i];
	int ans = min(abs(A[1] - A[0]) + abs(A[2] - A[0]), min(abs(A[0] - A[1]) + abs(A[2] - A[1]), abs(A[0] - A[2]) + abs(A[1] - A[2])));
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
const ll mod=1e9+7;
const int N=2e5+5;
const int M=20;

int main() 
{
    FAST;
    int a[4];
    int i;
    for(i=0;i<4;i++)
        cin >> a[i];
    sort(a,a+4);
    if(a[0]==1 && a[1]==4 && a[2]==7 && a[3]==9)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 1e5 + 7;

int dpl[N], dpr[N], a[N];

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i = 0; i < n + 1; i++) cin >> a[i];
	dpl[n] = dpr[n] = a[n];
	for(int i = n; i > 0; i--) {
		dpl[i - 1] = (dpl[i] + 1) / 2 + a[i - 1];
		dpr[i - 1] = dpr[i] + a[i - 1];
	}
	if(dpl[0] > 1 || dpr[0] < 1) {
		cout << -1 << endl;
		return 0;
	}
	int tt = 1;
	int ans = tt;
	for(int i = 0; i < n; i++) {
		tt -= a[i];
		int mx = tt * 2;
		tt = min(mx, dpr[i + 1]);
		ans += tt;
	}
	cout << ans << endl;
}





Measured memory_bytes: 5988
#pragma region header
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n,a,b;cin >> n >> a >> b;
    vi v(n);
    int count = 0;
    rep(i, n) {
        cin >> v[i];
        if(i>0) {
            if((v[i]-v[i-1])*a>=b) count+=b;
            else count +=(v[i]-v[i-1])*a;
        }
    }
    cout << count << endl;
    return 0;
}

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

int main()
{
    string s;
    cin >> s;

    int ans;
    if (s == "SAT"){
        ans = 1;
    } else if (s == "MON") {
        ans = 6;
    } else if (s == "TUE") {
        ans = 5;
    } else if (s == "WED") {
        ans = 4;
    } else if (s == "THU") {
        ans = 3;
    } else if (s == "FRI") {
        ans = 2;
    } else {
        ans = 7;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
#define int long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define endl '\n'
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define inf 1e18
#define pf push_front
#define pob pop_back
#define pof pop_front
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

typedef pair<int,int> pi;
typedef pair<int,pair<int,int>> piii;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;

int32_t main()
{
   // boost
    int t=1;
   // cin>>t;
    while(t--)
    {
        int n;
        cin>>n;

        map<string,int>mp;
        for(int i=0;i<n;i++)
        {
            string s;
            cin>>s;
            mp[s]++;

        }


        cout<<"AC x "<<mp["AC"]<<endl;
         cout<<"WA x "<<mp["WA"]<<endl;
          cout<<"TLE x "<<mp["TLE"]<<endl;
           cout<<"RE x "<<mp["RE"]<<endl;





    }


    

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>

int main(){
    ll A,B,C;
    cin>>A>>B>>C;
    if(A!=B&&B!=C&&C!=A)cout<<"No";
    else if(A==B&&B==C&&C==A)cout<<"No";
    else cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

    public class Main {
    	public static void main(String[] args){
    		 Scanner sc = new Scanner(System.in);
    		 String insert = sc.next();
    		 final String SEIKAI_YEAR = "2018";


    		 System.out.println(insert.replace("2017",SEIKAI_YEAR));
    	}
    }

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

#define forw(m,i,n) for(i=m; i<n; i++)
#define done return 0
#define in(x) cin >> x
#define out(x) cout << x << endl
#define pb(x) push_back(x)
#define w(x) while(x--)
#define maxx 1000000000

using namespace std;

typedef long long ll;


int main() {
    //freopen("output.txt","w",stdout);
    //freopen("input.txt","r",stdin);
    int n,m;
    in(n),in(m);
    if(n==m) cout << "Yes\n";
    else cout << "No\n";
    done;
}

Measured memory_bytes: 3640
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
using vi=vector<ll>;

template<class T> void out(T a){cout<<a<<endl;}

void solve() {
  ll n; cin>>n; vi a;
  rep(i,n){
    ll p; cin>>p;
    if(p%2==0) a.eb(p);
  }
  bool ok=true;
  rep(i,(ll)a.size()){
    if(a[i]%3!=0 && (a[i]%5)!=0){
      ok=false; break;
    }
  }
  if(ok) out("APPROVED");
  else out("DENIED");
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 256
import sys
n = int(input())
l = []
for i in range(n):
    w = input()
    if w in l:
        print("No")
        sys.exit()
    else:
        l.append(w)
        if len(l) > 1:
            if l[i-1][-1] != w[0]:
                print("No")
                sys.exit()
print("Yes")
sys.exit()


Measured memory_bytes: 2940
/**
 *    author:  tourist
 *    created: 13.06.2020 15:34:38       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b(n + 1);
  while (k--) {
    for (int i = 0; i <= n; i++) {
      b[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      int from = max(i - a[i], 0);
      int to = min(i + a[i], n - 1);
      b[from] += 1;
      b[to + 1] -= 1;
    }
    bool changed = false;
    for (int i = 0; i < n; i++) {
      changed |= (a[i] != b[i]);
      a[i] = b[i];
      b[i + 1] += b[i];
    }
    if (!changed) {
      break;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << a[i];
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 4788
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int n; cin >> n;
	cout << n/3 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int w,h;
int f(pair<int,int>a,pair<int,int>b)
{
	return abs(a.first-b.first)+abs(a.second-b.second);
}
main()
{
	while(cin>>w>>h,h)
	{
		vector<vector<pair<int,int> > >a(5);
		pair<int,int>S,G;
		for(int i=0;i<h;i++)
		{
			string s;cin>>s;
			for(int j=0;j<w;j++)
			{
				if(s[j]=='.')continue;
				else if(s[j]=='S')S.first=i,S.second=j;
				else if(s[j]=='G')G.first=i,G.second=j;
				else a[s[j]-'1'].push_back(make_pair(i,j));
			}
		}
		int cnt=0;
		for(int i=0;i<5;i++)cnt+=a[i].size()>0;
		if(cnt<4)
		{
			cout<<"NA"<<endl;
			continue;
		}
		int ansa,ansd=1e9;
		for(int i=0;i<5;i++)
		{
			vector<vector<int> >dp(5,vector<int>(1000,1e9));
			int j=(i+1)%5;
			for(int k=0;k<a[j].size();k++)dp[j][k]=f(S,a[j][k]);
			for(int cnt=3;cnt--;)
			{
				int l=(j+1)%5;
				for(int k=0;k<a[j].size();k++)for(int K=0;K<a[l].size();K++)
				{
					dp[l][K]=min(dp[l][K],dp[j][k]+f(a[j][k],a[l][K]));
				}
				j=l;
			}
			int now=1e9;
			for(int k=0;k<a[j].size();k++)
			{
				now=min(now,dp[j][k]+f(a[j][k],G));
			}
			if(ansd>now)
			{
				ansd=now;
				ansa=i+1;
			}
		}
		cout<<ansa<<" "<<ansd<<endl;
	}
}



Measured memory_bytes: 3192
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;
 
int dp[100000];
 
//Square Coins
int main(){
    int n;
 
    while(~scanf("%d",&n)){
        if(n==0) break;
 
        memset(dp,0,sizeof(dp));
 
        dp[0] = 1;
 
        for(int i=1;i<=17;i++){
            for(int k=1;k<=n;k++){
                if(k-i*i<0) continue;
                dp[k] += dp[k-i*i];
            }
        }
 
        printf("%d\n",dp[n]);
    }
}


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


def main():
    N = int(input())
    A = list(map(int, input().split()))

    index = list(range(N))
    forward = index.copy()
    forward[0] = 0
    for i in index[:-1]:
        forward[i+1] = gcd(A[i], forward[i])

    backward = index.copy()
    backward.append(0)
    for i in reversed(index):
        backward[i] = gcd(A[i], backward[i+1])
    # print(forward)
    # print(backward)
    M = [gcd(f, b) for f, b in zip(forward, backward[1:])]
    # print(M)
    print(max(M))


if __name__ == "__main__":
    main()


Measured memory_bytes: 14436
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//素因数分解 (配列)
vector<vector<ll>> prime_fact(ll n) {
	vector<vector<ll>> v(0);
	for (ll i = 2; i * i <= n; i++) {
		if (n % i) continue;
		ll cnt = 0;
		while (n % i == 0) {
			n /= i;
			cnt++;
		}
		v.push_back({i, cnt});
	}
	if (n > 1) v.push_back({n, 1});
	return v;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;

	vector<vector<ll>> v = prime_fact(n);

	ll ans = 0;
	for (auto i : v) {
		ll x = i[1], y = 1;
		while (x >= y) {
			ans++;
			x -= y;
			y++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3624
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize,
    }

    if n % 1000 == 0 {
        println!("0");
    } else {
        println!("{}", 1000 - n % 1000);
    }
}


Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef unsigned long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

#define THREAD (ll)1000'000'000'000'000'000

int main()
{
    int n;
    cin >> n;
    vector<ll> a;
    rep(i, n){ ll tmp; cin >> tmp; a.push_back(tmp);}
    rep(i, n){
        if (a[i] == 0){
            cout << "0" << endl; return 0;
        }
    }
    ll sum = 1;
    rep(i, n){
        ll div = THREAD/sum;
        if (div < a[i]){
            cout << "-1" << endl;
            return 0;
        }
        sum *= a[i];
    }
    cout << sum << endl;
}


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

typedef long long ll;

int main() {
  string S;
  cin >> S;

  int mi=1e9;
  for(int i=0; i<S.length()-2; i++){
    mi = min(mi, abs(753-stoi(S.substr(i,3))));
  }

  cout << mi << endl;
}

Measured memory_bytes: 256
k = int(input())
n = 1
cnt = 0
flg = 0
while True:
  if flg == 1:
    n += 1
  flg = 0
  strn = str(n)
  if len(strn) == 1:
    cnt += 1
    flg = 1
  else:
    for s in range(len(strn)):
      if s == len(strn) - 1:
        cnt += 1
        flg = 1
      else:
        if abs(int(strn[s]) - int(strn[s+1])) > 1:
          if int(strn[s]) - int(strn[s+1]) > 1:
            new = ''
            for ss in range(len(strn)):
              if s+1 == ss:
                new += str(int(strn[s]) - 1)
              else:
                new += strn[ss]
            n = int(new)
          else:
            new = ''
            for ss in range(len(strn)):
              if s == ss:
                new += str(int(strn[s]) + 1)
              elif s+1 == ss:
                new += '0'
              else:
                new += strn[ss]
            n = int(new)
          break
          
    
  if cnt == k:
    print(n)
    break


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
				int max = 0,total = 0,temp;
				int n = sc.nextInt();
		for(int i=0;i<n;i++) {
			temp = sc.nextInt();
			max = Math.max(temp, max);
			total += temp;
		}
		
		System.out.println(total - max / 2);
		sc.close();
	}

}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{

	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, ans =0; 
	string s, t;
	cin >>s >>t;
	
	rep(i, 3) if(s[i]==t[i]) ans++;
	cout << ans <<"\n";
	return 0;
	
	
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a < b {
		fmt.Println("a < b")
	} else if a > b {
		fmt.Println("a > b")
	} else {
		fmt.Println("a == b")
	}
}


Measured memory_bytes: 1124
#include <iostream>

int main()
{
    int r,m,l;

    std::cin >> r >> m >> l;

    long long *matA = new long long[r*m];
    long long *matB = new long long[m*l];
    long long *matC = new long long[r*l];

    for (int row = 0; row < r; row++)
        for (int col = 0; col < m; col++)
            std::cin >> matA[row*m+col];
    
    for (int row = 0; row < m; row++)
        for (int col = 0; col < l; col++)
            std::cin >> matB[row*l+col];


    for (int i = 0; i < r; i++)
        for (int j = 0; j < m; j++)
            for (int k = 0; k < l; k++)
                matC[i*l+k] += matA[i*m+j] * matB[j*l+k];
    
    for (int row = 0; row < r; row++)
        for (int col = 0; col < l; col++)
        {
            std::cout << matC[row*l+col];

            if (col < l-1) std::cout << " ";
            else           std::cout << std::endl;
        }   
}


Measured memory_bytes: 3332
n, m = map(int, input().split())
checker = [1 for _i in range(n+1)]
r = [0 for i in range(n+1)]
r[1] = 1
for _i in range(m):
    x, y = map(int, input().split())
    checker[x] -= 1
    checker[y] += 1
    if r[x]>0:
        r[y] = 1
    if (r[x]>0) and (checker[x]==0):
        r[x] = 0
print(sum(r))

Measured memory_bytes: 51420
S = input()
S_2 = list(map(int,S))

even = 0 #[0,1,0,1]
odd = 0 #[1,0,1,0]

for i,v in enumerate(S_2):
        if i % 2 == 0:
                #偶数
                if v == 0:
                        odd += 1
                else:
                        even += 1
        else:
                #偶数
                if v == 1:
                        odd += 1
                else:
                        even += 1

print(min(odd,even))

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

int main(){
  int N;
  cin >> N;
  int A[N], B[N], C[N - 1];
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  for(int i = 0; i < N; i++){
    cin >> B[i];
  }
  for(int i = 0; i < N - 1; i++){
    cin >> C[i];
  }
  
  int sat = 0;
  for(int i = 0; i < N; i++){
    sat += B[A[i] - 1];
    if(A[i] == A[i - 1] + 1){
      sat += C[A[i - 1] - 1];
    }
  }
  cout << sat << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,x;
    scanf("%d %d %d",&a,&b,&x);
    if(x<=a+b&&x>=a)
	     printf("YES");
	else
	     printf("NO");
	return 0;	      
    
}

Measured memory_bytes: 256
from heapq import heappush, heappop
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    N, M, S1, S2, T = map(int, readline().split())
    if N == 0:
        return False
    S1 -= 1; S2 -= 1; T -= 1
    G = [[] for i in range(N)]
    Gx = [[] for i in range(N)]
    L = 0
    for i in range(M):
        a, b, w = readline().strip().split()
        a = int(a)-1; b = int(b)-1
        if w == 'x':
            Gx[a].append(b)
            Gx[b].append(a)
            L += 1
        else:
            w = int(w)
            G[a].append((b, w))
            G[b].append((a, w))
    INF = 10**18
    dist = [[INF]*N for i in range(L+1)]
    que = [(0, T, 0)]
    while que:
        cost, v, k = heappop(que)
        if dist[k][v] < cost:
            continue
        dk0 = dist[k]

        for w, d in G[v]:
            if cost + d < dk0[w]:
                dk0[w] = cost + d
                heappush(que, (cost + d, w, k))
        if k+1 <= L:
            dk1 = dist[k+1]
            for w in Gx[v]:
                if cost < dk1[w]:
                    dk1[w] = cost
                    heappush(que, (cost, w, k+1))

    def check(f1, f2, f3):
        return (f2[0] - f1[0]) * (f3[1] - f2[1]) >= (f2[1] - f1[1]) * (f3[0] - f2[0])
    def f(f1, x):
        return f1[0]*x + f1[1]

    que1 = []
    que2 = []
    for a in range(L, -1, -1):
        if dist[a][S1] != INF:
            f1 = (a, dist[a][S1])
            while len(que1) >= 2 and check(que1[-2], que1[-1], f1):
                que1.pop()
            que1.append(f1)

        if dist[a][S2] != INF:
            f2 = (a, dist[a][S2])
            while len(que2) >= 2 and check(que2[-2], que2[-1], f2):
                que2.pop()
            que2.append(f2)
    m1 = len(que1); m2 = len(que2)
    ans = 10**18
    for i in range(m1):
        px0 = 0; px1 = 10**18
        ai, bi = que1[i]
        if i > 0:
            ci, di = que1[i-1]
            px0 = max((bi-di + ci-ai-1) // (ci-ai), 0)
        if i < m1-1:
            ci, di = que1[i+1]
            px1 = (di-bi) // (ai-ci)
        for j in range(m2):
            qx0 = 0; qx1 = 10**18
            aj, bj = que2[j]
            if j > 0:
                cj, dj = que2[j-1]
                qx0 = max((bj-dj + cj-aj-1) // (cj-aj), 0)
            if j < m2-1:
                cj, dj = que2[j+1]
                qx1 = (dj-bj) // (aj-cj)
            x0 = max(px0, qx0); x1 = min(px1, qx1)
            if not x0 <= x1:
                continue
            ans = min(ans, abs((ai - aj)*x0 + (bi - bj)), abs((ai - aj)*x1 + (bi - bj)))
            if ai != aj:
                x = (bj - bi) // (ai - aj)
                if x0 <= x <= x1:
                    ans = min(ans, abs((ai - aj)*x + (bi - bj)))
                if x0 <= x+1 <= x1:
                    ans = min(ans, abs((ai - aj)*(x+1) + (bi - bj)))
    write("%d\n" % ans)
    return True
while solve():
    ...


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

using namespace std;

#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll n[5];
	forn(i,5){
		cin>>n[i];
	}
	forn(i,5){
		if(n[i]==0)cout<<i+1<<"\n";
	}
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 3596
import random
import copy


def main():
    D = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(D)]

    t = [0] * D

    # ペナルティが多い順にindexを並べる
    penalty = copy.deepcopy(c)
    for i in range(D):
        t[i] = penalty.index(max(penalty)) + 1
        penalty[t[i]-1] = 0
        for j in range(26):
            penalty[j] += c[j]

    for tt in t:
        print(tt)


def calc(s, c, t):
    d = [0] * 26

    ans = 0
    days = 0
    for tt in t:
        for i in range(26):
            d[i] += 1
        d[tt-1] = 0
        ans += s[days][tt-1]
        for i in range(26):
            ans -= d[i] * c[i]
        days += 1
        print(ans)

    return ans


if __name__ == "__main__":
    main()


Measured memory_bytes: 78080
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<unordered_map>

using ull = unsigned long long;
using ll = long long;
using namespace std;

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

    vector<int> memo(100000,0);

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

    // solve
    int maxn = memo[0] + memo[1];
    for(int i = 1; i < 99999; ++i) {
        int temp = memo[i-1] + memo[i] + memo[i+1];
        if (temp > maxn) {
            maxn = temp;
        }
    }

    cout << maxn << endl;

    return 0;
}

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

int main(){
    int n,m;
    map<string,int> card;
    cin >> n;
    for(int i=0;i<n;++i){
        string s;
        cin >> s;
        card[s]++;
    }
    cin >> m;
    for(int i=0;i<m;++i){
        string t;
        cin >> t;
        card[t]--;
    }
    int ans = 0;
    for(auto itr=card.begin();itr!=card.end();++itr){
        if(ans< (itr->second)) ans = itr->second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  int N, A, B, ret = 0;
  cin >> N >> A >> B;
  for (int i = 1; i <= N; i++) {
    int tmp = i, s = 0;
    while (tmp) {
      s += tmp % 10;
      tmp /= 10;
    }
    if (A <= s && s <= B) ret += i;
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static int[] a = new int[4];
	public static char[] op = new char[3];
	public static void dfs( int n ) {
		if( n == 3 ) {
			int sum = a[0];
			for( int i = 0; i < 3; i++ ) {
				if( op[i] == '+'  )
					sum += a[i+1];
				else
					sum -= a[i+1];
			}
			if(sum == 7) {
				for( int i = 0; i < 4; i++ ) {
					if( i != 3 )
						System.out.print( a[i] + "" + op[i] );
					else
						System.out.println( a[i] + "=7" );
				}
				System.exit(0);
			}
		}
		else {
			op[n] = '+';
			dfs(n+1);
			op[n] = '-';
			dfs(n+1);
		}
	}
	
	public static void main(String args[] ) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		a[0] = s.charAt(0)-'0';
		a[1] = s.charAt(1)-'0';
		a[2] = s.charAt(2)-'0';
		a[3] = s.charAt(3)-'0';
		dfs(0);
		sc.close();
	}
}

Measured memory_bytes: 39300
N,M,Q = map(int,input().split())
query = [None] * Q
for i in range(Q):
  query[i] = list(map(int,input().split()))
  
def calc(arr,query):
  res = 0
  for a,b,c,d in query:
    if arr[b-1] - arr[a-1] == c:
      res += d
  return res
  
ans = 0
import itertools
for arr in itertools.combinations_with_replacement(range(1,M+1),N):
  val = calc(arr,query)
  if ans < val:
    ans = val
print(ans)

Measured memory_bytes: 9016
def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    A = [input().rstrip('\n') for _ in range(N)]
    B = [input().rstrip('\n') for _ in range(N)]

    for i in range(N-M+1):
        for j in range(N-M+1):
            ok = 1
            for k in range(M):
                for l in range(M):
                    if A[i+k][j+l] != B[k][l]:
                        ok = 0
            if ok:
                print('Yes')
                exit()
    print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 40304
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
ll solve(ll n) 
{ 

  
    switch(n & 3) // n % 4  
    { 
    case 0: return n;     // if n is multiple of 4 
    case 1: return 1;     // If n % 4 gives remainder 1   
    case 2: return n + 1; // If n % 4 gives remainder 2     
    case 3: return 0;     // If n % 4 gives remainder 3   
    } 
} 
int main()
{
	sync;
	ll a,b,ans;
	cin>>a>>b;
	if(a)
	ans=solve(a-1)^solve(b);
	else
	ans=solve(b);
	cout<<ans<<endl;
}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
  int x,y;
  cin>>x>>y;
  if(x<y) swap(x,y);
  while(x%y)
  {
    x%=y;
    swap(x,y);
  }
  cout<<y<<endl;
  return 0;
}


Measured memory_bytes: 3100