akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> P(N);
  rep(i, N) cin >> P[i];
  vector<int> ord(N-1);
  rep(i, K-1) if(P[i+1]-P[i]>0) ord[0]++;
  REP(i, 1, N-K+1) {
    ord[i] = ord[i-1];
    if(P[i]-P[i-1]>0) ord[i]--;
    if(P[i+K-1]-P[i+K-2]>0) ord[i]++;
  }
  int cntOrd = 0;
  rep(i, N-K+1) if(ord[i] == K-1) cntOrd++;
  set<int> se;
  rep(i, K+1) se.insert(P[i]);
  int cnt = 0;
  rep(i, N-K) {
    if(ord[i+1] != K-1 && *se.begin() == P[i] && *(--se.end()) == P[i+K]) cnt++;
    se.erase(P[i]);
    se.insert(P[i+K+1]);
  }
  cout << N-K+1-max(cntOrd-1, 0)-cnt << endl;
  return 0;
}


Measured memory_bytes: 11136
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
using namespace std;
typedef long long LL;
typedef complex<double> C;
double dot(C a, C b)
{
	return real(a)*real(b)+imag(a)*imag(b);
}
const double eps=1e-9;
int N;
C ps[500];
double rs[500][2];
int ret=1;
void exec4(C v, double c)
{
	int cnt=0;
	for(int i=0;i<N;i++){
		double w=abs(dot(ps[i],v)-c);
		//cout << w << ": " << rs[i][0] - eps << ": " << rs[i][1] + eps<< endl;
		if (rs[i][0]-eps<=w&&w<=rs[i][1]+eps)
		{
			//cout << "ok" << endl;
			cnt++;
		}
		else
		{
		//cout << "ng" << endl;
		}
	}
	
	/*
	if (cnt < 2){
		cout << cnt << ", " << v << ", " << c << endl;
	}*/
	ret=max(cnt,ret);
}

void solve(double a, double b, double c, C ans[2])
{
	bool sw=false;
	if (b==0){
		swap(a,b);
		sw=true;
	}

	double s=-a/b;
	double t=c/b;
	double p=1+s*s;
	double q=2*s*t;
	double r=t*t-1;
	/*
	if (q*q-4*p*r<0){
		cout << "aaa " << endl;
	}*/
	double x0=(-q-sqrt(q*q-4*p*r))/(2*p);
	double y0=s*x0+t;
	double x1=(-q+sqrt(q*q-4*p*r))/(2*p);
	double y1=s*x1+t;
	if(!sw){
		ans[0]=C(x0,y0);
		ans[1]=C(x1,y1);
	}
	else
	{
		ans[0]=C(y0,x0);
		ans[1]=C(y1,x1);
	}
}
void exec3(C q, C p, double r)
{
	if (abs(q-p)<r-eps){
		return;
	}

	C v[2];
	int cnt;
	if (abs(q-p)<=r+eps){
		v[0]=(q-p)/abs(q-p);
		cnt=1;
	}
	else
	{
		solve(real(p-q),imag(p-q),r,v);
		cnt=2;
	}
	for(int i=0;i<cnt;i++){
		double c=dot(v[i],q);
		exec4(v[i],c);
	}
}
void exec2(C p1, double r1, C p2, double r2)
{
	if (r1>r2){
		swap(p1,p2);
		swap(r1,r2);
	}

	C q=(r2*p1+r1*p2)/(r1+r2);
	//cout << "aaa " << endl;
	exec3(q,p1,r1);

	if(r1!=r2){
		q=(r2*p1-r1*p2)/(r2-r1);
		//cout << "bbb " << endl;
		exec3(q,p1,r1);
	}
	else
	{
		C v=(p2-p1)/abs(p2-p1)*C(0,1)*r1;
		exec3(p1+v,p1,r1);
		exec3(p1-v,p1,r1);
	}
}
void exec()
{
	cin >> N;
	if(N==0){
		exit(0);
	}

	for(int i=0;i<N;i++){
		int x,y;
		cin >> x >> y >> rs[i][0] >> rs[i][1];
		rs[i][1]+=rs[i][0];
		ps[i]=C(x,y);
	}

	ret=1;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			for(int s=0;s<2;s++){
				for(int t=0;t<2;t++){
					exec2(ps[i],rs[i][s],ps[j],rs[j][t]);
				}
			}
		}
	}
	cout << ret << endl;
}

int main() {
	while(1)
		exec();
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const LL mod=998244353;
#define mem(a,b) memset(a,b,sizeof(a))
int max(int a,int b) {return a>b?a:b;}

int main()
{
    int n,h,w;
    scanf("%d%d%d",&n,&h,&w);
    printf("%d\n",(n-w+1)*(n-h+1));
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

typedef long long ll;
const int MAXN=1e5+5;

int n,m,s,t;
struct node{
    int a,b;
    int v;
    node(int _v,int _a,int _b){v=_v,a=_a,b=_b;}
};
vector <node> E[MAXN];

ll ans[MAXN];
ll d1[MAXN],d2[MAXN];
bool vis[MAXN];
queue <int> q;

void spfa1(){
    memset(vis,0,sizeof vis);
    memset(d1,-1,sizeof d1);
    while(!q.empty()) q.pop();
    int u=s;
    vis[u]=1; d1[u]=0;
    q.push(u);
    while(!q.empty()){
        u=q.front(); q.pop(); vis[u]=0;
        for(int i=0;i<(int)E[u].size();i++){
            int v=E[u][i].v,val=E[u][i].a;
            if(d1[v]==-1||d1[v]>d1[u]+val){
                d1[v]=d1[u]+val;
                if(!vis[v]){
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
}

void spfa2(){
    memset(vis,0,sizeof vis);
    memset(d2,-1,sizeof d2);
    while(!q.empty()) q.pop();
    int u=t;
    vis[u]=1; d2[u]=0;
    q.push(u);
    while(!q.empty()){
        u=q.front(); q.pop(); vis[u]=0;
        for(int i=0;i<(int)E[u].size();i++){
            int v=E[u][i].v,val=E[u][i].b;
            if(d2[v]==-1||d2[v]>d2[u]+val){
                d2[v]=d2[u]+val;
                if(!vis[v]){
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
}

int main(){
    scanf("%d%d%d%d",&n,&m,&s,&t);
    for(int i=1;i<=m;i++){
        int u,v,a,b;
        scanf("%d%d%d%d",&u,&v,&a,&b);
        E[u].push_back(node(v,a,b));
        E[v].push_back(node(u,a,b));
    }
    spfa1();
    spfa2();
    ll mine=1e15;
    for(int i=n;i>=1;i--){
        //printf("#%d %lld,%lld\n",i,d1[i],d2[i]);
        ans[i]=min(mine,d1[i]+d2[i]);
        mine=min(mine,d1[i]+d2[i]);
    }
    for(int i=1;i<=n;i++)
        printf("%lld\n",ll(1e15)-ans[i]);
}


Measured memory_bytes: 10880
#include<iostream>
using namespace std;
int main(){
    long long n;
    cin>>n;
    int min0;
    for(long long i=1;i*i<=n;i++){
    	if(n%i==0){
    		int a=n/i;
    		min0=0;
    		while(a){
    			min0++;
    			a/=10;
			}
		}
	}
	cout<<min0<<endl;
}

Measured memory_bytes: 256
s = gets.chomp
result = ""

if s.length % 2 == 0 then
    n = s.length / 2
else (s.length + 1) / 2
    n = (s.length + 1) /2
end

for i in 1..n do
    result += s[2 * i - 2]
end

print result

Measured memory_bytes: 63440
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
  }
  sort(v.begin(), v.end());
  double ans = v[0];
  for (int i = 1; i < n; i++) {
    ans = (ans + v[i]) / 2;
  }
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int r, c, k; cin >> r >> c >> k;
  vector item(r, vector(c, -INF));
  while (k--) {
    int y, x, v; cin >> y >> x >> v; --y; --x;
    item[y][x] = v;
  }
  vector dp(r, vector(c, vector(4, -LINF)));
  dp[0][0][0] = 0;
  dp[0][0][1] = item[0][0];
  REP(i, r) REP(j, c) REP(k, 4) {
    if (i + 1 < r) {
      chmax(dp[i + 1][j][0], dp[i][j][k]);
      chmax(dp[i + 1][j][1], dp[i][j][k] + item[i + 1][j]);
    }
    if (j + 1 < c) {
      chmax(dp[i][j + 1][k], dp[i][j][k]);
      if (k + 1 <= 3) chmax(dp[i][j + 1][k + 1], dp[i][j][k] + item[i][j + 1]);
    }
  }
  cout << *max_element(ALL(dp[r - 1][c - 1])) << '\n';
  return 0;
}


Measured memory_bytes: 670960
n,m,x = map(int,input().split())
books = [list(map(int, input().split())) for _ in range(n)]

ans = []

for i in range( 2 ** n ):
    total = [0] * (m + 1)
    for j in range(n):
        if (i >> j) & 1:
            total = [total[k] + books[j][k] for k in range(m+1)]

    over = True
    for j in range(1, m+1):
        if total[j] < x:
            over = False
    if over:
        ans.append(total[0])

if len(ans) > 0:
    print(min(ans))
else:
    print('-1')


Measured memory_bytes: 9300
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n;
    cin >> n;
    vector<string> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vi row(n, 0), col(n, 0);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (a[i][j] == '#') {
                row[i]++;
                col[j]++;
            }
        }
    }
    bool blackrow = false;
    ll whitecol   = 0;
    ll allwhite   = 0;
    for (int i = 0; i < n; ++i) {
        if (row[i] == n)
            blackrow = true;
        if (col[i] != n)
            whitecol++;
        if (col[i] == 0)
            allwhite++;
    }
    if (blackrow) {
        cout << whitecol << "\n";
        return 0;
    }
    if (allwhite == n) {
        cout << -1 << "\n";
        return 0;
    }
    ll ret = INF;
    for (int i = 0; i < n; ++i) {
        ll temp = 0;
        if (col[i] == 0)
            temp++;
        temp += n - row[i];
        temp += whitecol;
        chmin(ret, temp);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int INF = 1e+12;
int w, h;
int s[1000][1000];
int rs[1000][1001];
int dp[1001][1001];

int Abs(int x) { if (x > 0) return x; return -x; }

//(y, x)??\?????§?????????????????????????????¢
int dfs(int y, int x) {
	if (y == h && x == w) return 0;
	if (dp[y][x] != -1) return dp[y][x];
	
	if ((y + x) % 2 == 0) {
		int ret = -INF;
		if (x < w) ret = max(ret, dfs(y, x + 1));
		if (y < h) ret = max(ret, rs[y][w] - rs[y][x] + dfs(y + 1, x));
		return dp[y][x] = ret;
	}
	
	int ret = INF;
	if (x < w) ret = min(ret, dfs(y, x + 1));
	if (y < h) ret = min(ret, rs[y][w] - rs[y][x] + dfs(y + 1, x));
	return dp[y][x] = ret;
}

signed main() {
	int i, j;
	
	cin >> w >> h;
	for (i = 0; i < h; i++) for (j = 0; j < w; j++) cin >> s[i][j];
	for (i = 0; i <= h; i++) for (j = 0; j <= w; j++) dp[i][j] = -1;
	
	int ssum = 0;
	for (i = 0; i < h; i++) {
		rs[i][0] = 0;
		for (j = 1; j <= w; j++) {
			ssum += s[i][j - 1];
			rs[i][j] = rs[i][j - 1] + s[i][j - 1];
		}
	}
	cout << Abs(2 * dfs(0, 0) - ssum) << endl;
	return 0;
}

Measured memory_bytes: 26652
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,M=MAP()

imos=[0]*(N+1)
for i in range(M):
    l,r=MAP()
    imos[l-1]+=1
    imos[r]-=1

acc=list(accumulate(imos))

mx=max(acc)
if mx==M:
    print(acc.count(mx))
else:
    print(0)


Measured memory_bytes: 8112
L, R, d = map(int, input().split())

tmp = L
for i in range(L, R + 1):
    if i % d == 0:
        tmp = -1
        L = i
        break


count = 0
if tmp != L:
    for i in range(L, R + 1, d):
        count += 1

print(count)

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

public class Main {
  private static int solve(String s) {
    String[] list = new String[] {
      "SAT",
      "FRI",
      "THU",
      "WED",
      "TUE",
      "MON",
      "SUN",
    };
    for (int i = 0; i < list.length; i++) {
      if (s.equals(list[i])) {
        return i + 1;
      }
    }
    throw new RuntimeException();
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    String s  = reader.next();
    out.println(solve(s));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

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

	int l = d/100;
	int r = d%100;

	if(1<=l && l<=12){
		if(1<=r && r<=12) cout << "AMBIGUOUS" << endl;
		else cout << "MMYY" << endl;
	}
	else{
		if(1<=r && r<=12) cout << "YYMM" << endl;
                else cout << "NA" << endl;
	}
}

Measured memory_bytes: 3604
#include <cstdio>
#include <set>
using namespace std;
set<int>s;
int main()
{
   int n;
  
   scanf("%d",&n);
   while(n--)
   {
   	int a;
   	scanf("%d",&a);
   	if(s.count(a)==1)
   	s.erase(a);
   	else 
   	s.insert(a);
   }
   printf("%d",s.size());
   
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
int main(void){
  // Your code here!
  long long int n,k;
  cin>>n>>k;
  
  long long int sum=0;
  while((n-k+1)*k >= 0){
    sum += (n-k+1)*k+1;
    k++;
  }

  cout<<sum%(1000000007)<<endl;
  
  
  
}


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

int main() {
	//int op;

	int a, b, c,bol=0;

	cin >> a >> b >> c;

	if (a == 5) {
		if (b == 5) {
			if (c == 7) {
				bol = 1;
			}
		}
		if (b == 7) {
			if (c == 5) {
				bol = 1;
			}
		}
	}

	if (a == 7) {
		if (b == 5 && c == 5) {
			bol = 1;
		}
	}

	if (bol == 0) {
		cout << "NO";
	}
	else {
		cout << "YES";
	}
	//cin >> op;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin>>s;
  int n=s.size();

  if(s[0]=='0'||s[n-1]=='1'||s[n-2]=='0'){
    cout<<-1<<endl;
    return 0;
  }
  for(int i=0;i<n-1;i++){
    if(s[i]!=s[n-i-2]){
      cout<<-1<<endl;
      return 0;
    }
  }

  vector<int> w,v;
  int pa=1;
  
  for(int i=0;i<n-1;i++){
    if(s[i]=='1'){
      w.push_back(pa);
      v.push_back(i+2);
      pa=i+2;
    }else{
      w.push_back(pa);
      v.push_back(i+2);
    }
  }

  for(int i=0;i<w.size();i++){
    cout<<w[i]<<" "<<v[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 2548
n = int(input())
li = list(map(int, input().split()))

li = reversed(li)
kotae = 0
nex = 10000000000

for i in li:
	if i <= nex:
		nex = i
		pass
	elif i-1 <= nex:
		nex =i-1
		pass
	else:
		print('No')
		break
	kotae += 1
if kotae == n:
	print('Yes')
	

Measured memory_bytes: 14396
#include <iostream>


using namespace std;

int main()
{
	while(true)
	{
		int x, y;
		cin >> x >> y;
		if(x == 0 && y == 0)
		{
			break;
		}
		if(x > y)
		{
			cout << y << " " << x << endl;
		}
		else
		{
			cout << x << " " << y << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3008
#4問目
import sys
from collections import deque

N, M = map(int, input().split())
#どこの配列番号と繋がっているか保存
link = [[] for i in range(N)]

for i in range(M):
    A, B = map(int, input().split())
    link[A-1].append(B-1)
    link[B-1].append(A-1)
visited = [False for _ in range(N)]
visited[0] = True

Q = [0]
mark = [0 for i in range(N)]

while Q:
    #v:= 階層(0からはじまり)
    v = Q.pop(0)
    for i in link[v]:
        if not visited[i]:
            visited[i] = True
            mark[i] = v
            Q.append(i)

print("Yes")
for i in range(1, N):
    print(mark[i] + 1)

Measured memory_bytes: 35136
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define pii pair<int, int>
#define ll long long

const int N = 505;

int n, n2, Mod;
pii a[N];
int cnt[N];
int dp[2][N];

int main() {
	scanf("%d%d", &n, &Mod);
	n2 = n << 1;
	int p1 = 0, p2 = 0, N4 = 4 * n * n, N2 = n * n;
	for (int i = n2 - 1; ~i; i--) {
		while (p1 < n2 && p1 * p1 <= N4 - i * i)
			p1++;
		while (p2 * p2 < N2 - i * i)
			p2++;
		if (p2) {
			a[i] = pii(p2, p1);
		} else {
			a[i] = pii(p1, 0);
		}
	}
	sort(a, a + n2);
	cnt[0] = 0;
	for (int i = 0; i < n2; i++)
		cnt[i + 1] = cnt[i] + !a[i].second;
	ll ans = 0;
	for (int i = 0; i <= n; i++) {
		int cur = 0;
		memset(dp[0], 0, sizeof(dp[0]));
		dp[0][0] = 1;
		for (int j = 0; j < n2; j++) {
			memset(dp[cur ^= 1], 0, sizeof(dp[0]));
			for (int k = 0; k <= i; k++) {
				if (!a[j].second) {
					dp[cur][k] = (dp[cur][k] + 1ll * (a[j].first - k - cnt[j]) * dp[cur ^ 1][k]) % Mod;
				} else {
					dp[cur][k + 1] = (dp[cur][k + 1] - 1ll * (a[j].first - k - cnt[j]) * dp[cur ^ 1][k]) % Mod;
					dp[cur][k] = (dp[cur][k] + 1ll * (a[j].second - (n + i + j - cnt[j] - k)) * dp[cur ^ 1][k]) % Mod;
				}
			}
		}
		ans += dp[cur][i];
	}
	ans %= Mod;
	(ans < 0) && (ans += Mod);
	printf("%d\n", (int) ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define write(x) printf("%d\n", x)
using namespace std;
typedef long long ll;
template <typename T>
void read(T &x)
{
	x = 0;
	char c;
	while (!isdigit(c = getchar()));
	do
	{
		x = (x << 1) + (x << 3) + (c ^ 48);
	}while (isdigit(c = getchar()));
}
int n, k;
ll h[200005];
ll sum;
int main()
{
	read(n);read(k);
	for (int i = 0;i < n;++i)
	{
		read(h[i]);
	}
	if (k >= n)
	{
		puts("0");
		return 0;
	}
	sort(h, h + n);
	int r = n - k;
	for (int i = 0;i < r;++i)
		sum += h[i];
	printf("%lld\n", sum);
	return 0;
}



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

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  char now='1';
  vector<int>zo(1, 0);
  for(int i=0; i<n; i++){
    if(s[i]==now)zo[zo.size()-1]++;
    else {
      now=s[i];
      zo.push_back(1);
    }
  }
  if(now=='0')zo.push_back(0);
  if(zo.size()<=2*k+1){
    cout << s.size();
    return 0;
  }
  int cnt=0, ret=0;
  for(int i=0; i<2*k+1; i++)cnt+=zo[i];
  ret=cnt;
  for(int i=2*k+1; i<zo.size(); i+=2){
    cnt-=zo[i-2*k-1]+zo[i-2*k];
    cnt+=zo[i]+zo[i+1];
    ret=max(ret, cnt);
  }
  cout << ret;
  return 0;
}


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,k,flag=0;
  cin>>k;
  cin>>a>>b;
  for(a;a<=b;a++)
  {
    if(a%k==0)
    {
      flag=1;
      break;
  }
  }
  if(flag==1)
    cout<<"OK";
  else
    cout<<"NG";
  
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std;

class Solver {

};

int cnt = 0;

vector<int> merge(vector<int> left, vector<int>right) {
	vector<int> ret(left.size() + right.size());
	int left_i = 0;
	int right_i = 0;
	for (int i = 0; i < ret.size(); i++) {
		if (right_i == right.size()) {
			ret[i] = left[left_i];
			left_i++;
		}
		else if (left_i == left.size()) {
			ret[i] = right[right_i];
			right_i++;
		}
		else if (left[left_i] <= right[right_i]) {
			ret[i] = left[left_i];
			left_i++;
		}
		else {
			ret[i] = right[right_i];
			right_i++;
		}
		cnt++;
	}
	return ret;
}

vector<int> mergeSort(vector<int> ar) {
	if (ar.size() == 1)return ar;
	int mid = ar.size() / 2;
	vector<int> left(mid);
	vector<int> right(ar.size() - mid);
	for (int i = 0; i < ar.size(); i++) {
		if (i < mid)left[i] = ar[i];
		else right[i - mid] = ar[i];
	}

	left = mergeSort(left);
	right = mergeSort(right);
	return merge(left, right);
}

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

	vector<int> sorted = mergeSort(ar);
	for (int i = 0; i < n; i++) {
		cout << sorted[i];
		if (i < n - 1)cout << " ";
	}
	cout << endl;

	cout << cnt << endl;
}


Measured memory_bytes: 14204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<ll> d(n);
    using P = pair<ll, ll>;
    vector<P> p(n);
    for(int i = 0; i < n; i++)
    {
        cin >> d[i];
        p[i] = P(d[i], i+1);
    }
    sort(d.begin(), d.end());
    sort(p.begin(), p.end());

    vector<int> num(n);
  vector<P> ans;
    vector<ll> dis(n);
    for(int i = n-1; i >= 1; i--)
    {
        num[i]++;
        ll cand = d[i] - n + 2 * num[i];
        int x = lower_bound(d.begin(), d.end(), cand) - d.begin();
        if(x >= i || d[x] != cand)
        {
            cout << -1 << endl;
            return 0;
        }
        num[x] += num[i];
        dis[x] = dis[x] + dis[i] + num[i];
        ans.push_back(P(x, i));
    }
    if(dis[0] != d[0])
    {
      cout << -1 << endl;
      return 0;
    }
    for(int i = 0; i < ans.size(); i++)
    {
        cout << p[ans[i].first].second << " " << p[ans[i].second].second << endl;
    }
}


Measured memory_bytes: 6640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
	ll X, K, D;
	cin >> X >> K >> D;
	X=abs(X);
	ll f=X/D, ans;
	if(K<=f) ans=X-K*D;
	else if((K-f)%2==0){
	    ans=X-f*D;
	    if(K>=f+2) ans=min(ans, (f+2)*D-X);
	}
	else{
	    ans=X-(f-1)*D;
	    if(K>=f+1) ans=min(ans, (f+1)*D-X);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main()
{
  int N, //数列の長さを表す整数 N
      A[1000], key, i, j, k;


  /*入力*/
  scanf("%d", &N);
  if(N < 1 || 100 < N)
    printf("ERROR:1以上100以下の数列の長さを入力してください。");

  for(i = 0; i < N; i++)
    scanf("%d", &A[i]);



  /*挿入ソート*/
  for(i = 0; i < N; i++) //i が 1 から N-1 まで
  {
    key = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > key)
    {
      A[j + 1] = A[j];
      j--;
      A[j + 1] = key;
    }
    for(k = 0; k < N - 1; k++)
    {
      printf("%d ", A[k]);
    }
    printf("%d\n", A[k]);
  }
  return 0;
}


Measured memory_bytes: 2036
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int a,b,c;
	cin >> a >> b >> c;

  	if(a+b<c){
		cout << "No" << endl;
    }else{
		cout << "Yes" << endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);


int main() {
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    sort(ALL(a));
    /*
    a.erase(unique(ALL(a)), a.end());
    N = a.size();
     */
    ll res = 0;
    rep(i,N){
        rep(j,i){
            rep(k, j){
                res += (a[k] + a[j] > a[i] && a[i] != a[j] && a[j] != a[k]);
                //if(a[k] + a[j] > a[i] && a[i] != a[j] && a[j] != a[k]) cout<<i + 1<<' '<<j + 1<<' '<<k + 1<<endl;
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
using ll = long long;
using ld = long double;
const int N = 1e5+10;

ll n, m, v, p;
int a[N];

bool check(int x) { // can x be selected?
  ll score = a[x] + m;
  ll rem = 1LL * (v-1) * m;
  int k = 0;
  for (int i = 0; i < n; i++) {
    if (i == x) continue;
    if (a[i] > score) {
      k++;
      rem -= m;
    } else if (k < p-1) {
      k++;
      rem -= m;
    } else {
      rem -= min(m, score - a[i]);
    }
  }
  return k <= p-1 && rem <= 0;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> v >> p;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n, greater<int>());
  int l = p, r = n-1, ans = p-1;
  while (l <= r) {
    int m = (l+r)/2;
    if (check(m)) {
      ans = m;
      l = m+1;
    } else r = m-1;
  }
  cout << ans+1 << nl;
}


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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/d.in", "r", stdin);
//  freopen("../IO/d.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


void solve(std::istream &in, std::ostream &out) {
  int64_t a, b, n;
  in >> a >> b >> n;
  int mx = 0;
  for (int x = a - 1; x >= 0; --x) {
    int64_t left = (b*x + a - 1)/a, right = (b*(x+1)) % a == 0 ? (b*(x+1))/a-1 : (b*(x+1))/a;
//    cout << left << ' ' << right << '\n';
    if (left <= right && (n >= right || (right > n && left <= n))) {
      mx = x;
      break;
    }
  }
  out << mx << '\n';
}



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

using namespace std;

int main(){
  int n; cin >> n;
  int sum = 0;

  int t[n];
  for(int i = 1; i <= n; i++){
    cin >> t[i];
    sum += t[i];
  }
  const int sum_ans = sum;

  int m; cin >> m;

  int p[m], x[m];

  int ans[m];
  for(int i = 1; i <= m; i++){
    cin >> p[i] >> x[i];
  }

  for(int i = 1; i <= m; i++){
    ans[i] = sum_ans + x[i] - t[p[i]];
  }

  for(int i = 1; i <= m; i++){
    cout << ans[i] << endl;
  }
}

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

int main(){
  int X;
  cin >> X;
  int K = 1;
  while(true){
    if((K*X)%360==0){
      cout << K << endl;
      return 0;
    }
    K++;
  }
}

Measured memory_bytes: 3640
x, a, b = input().split()
x = int(x)
a = int(a)
b = int(b)
# print("x = ", x)
# print("a = ", a)
# print("b = ", b)

if x < a:
    distance_xa = a - x
else:
    distance_xa = x - a
# print("distance_xa = ", distance_xa)

if x < b:
    distance_xb = b - x
else:
    distance_xb = x - b
# print("distance_xb = ", distance_xb)

if distance_xa < distance_xb:
  print("A")
else:
  print("B")

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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b, c;
  cin >> a >> b >> c;
  if((a == b || a == c || b == c) && (a != b  || b != c || c != a)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

VVI _array;
VI info_member;
int n, m;

int main() {
	while ( ~scanf( "%d", &n ) && n ) {
		_array.resize( n );
		for ( int i = 0; i < n; i++ ) {
			scanf( "%d", &m );
			_array[ i ].resize( m );
			for ( int j = 0; j < m; j++ ) {
				scanf( "%d", &_array[ i ][ j ] );
			}
			sort( _array[ i ].begin(), _array[ i ].end() );
		}
		scanf( "%d", &m );
		info_member.resize( m );
		for ( int i = 0; i < m; i++ ) {
			scanf( "%d", &info_member[ i ] );
		}
		sort( info_member.begin(), info_member.end() );
		int ans = 0;
		for ( int i = 0; i < n; i++ ) {
			if ( _array[ i ].size() >= info_member.size() ) {
				bool is_can = true;
				for ( int j = 0; j < info_member.size(); j++ ) {
					if ( !(binary_search( _array[ i ].begin(), _array[ i ].end(), info_member[ j ] )) ) {
						is_can = false;
						break;
					}
				}
				if ( is_can ) {
					if ( ans ) {
						ans = -1;
					}
					else {
						ans = i + 1;
					}
				}
			}
		}
		printf( "%d\n", ans ? ans : -1 );
	}
	return 0;
}

Measured memory_bytes: 1280
n = int(input())
A = [*map(int, input().split())]
q = int(input())
BC = [[*map(int, input().split())] for _ in range(q)]

C = {}
for a in A:
    if a in C: C[a] += 1
    else: C[a] = 1

s = sum(A)
for b, c in BC:
    if not b in C: C[b] = 0
    if not c in C: C[c] = 0
    s += (c - b) * C[b]
    C[c] += C[b]
    C[b] = 0
    print(s)


Measured memory_bytes: 39652
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    q:usize,
    h:usize,
    s:usize,
    d:usize,
    n:usize,
    }
    println!("{}",(n/2)*min(8*q,min(4*h,min(2*s,d)))+(n%2)*min(4*q,min(2*h,s)))
}

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

ll n, k, sum = 1, mod = 1000000007;

ll gauss(ll n)
{
    return (n * (n + 1) / 2) % mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    while (k <= n)
    {
        ll min = gauss(k - 1);
        ll max = (gauss(n) - gauss(n - k) + mod) % mod;
        sum += (max - min + 1 + mod) % mod;
        k++;
    }

    cout << sum % mod;
    cin >> n;
}

Measured memory_bytes: 3644
function main(input) {
  let [n, k] = input[0].trim().split(" ").map(i => parseInt(i));
  
  let a = [];
  for(let i=0;i<k;i++){
    let d = parseInt(input[i*2+1]);
    const kari = input[i*2+2].trim().split(" ").map(i => parseInt(i));
    for(let j=0;j<d;j++){
       a.push(kari[j]);
    }
  }
  const b = a.filter(function (x, i, self) {
    return self.indexOf(x) === i;
  });
  console.log(n-b.length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 30356
#include <bits/stdc++.h>
using namespace std;
#define int long long 
int32_t main() {
	int n,m;
	cin>>n>>m;
	if(n%3==0 or m%3==0){
		cout<<0;
		return 0;
	}
	int ans=100000000009;
	for(int i=1;i<=n;i++){
		int a1=i*m;
		int a2=(m/2)*(n-i);
		int a3=n*m-a2-a1;
		ans=min(ans,max(a1,max(a2,a3))-min(a1,min(a2,a3)));
	}
	swap(n,m);
	for(int i=1;i<=n;i++){
		int a1=i*m;
		int a2=(m/2)*(n-i);
		int a3=n*m-a2-a1;
		ans=min(ans,max(a1,max(a2,a3))-min(a1,min(a2,a3)));
	}
	cout<<min(ans,min(n,m));
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int sum_digit(int num) {
    int sum = 0;
    while(num > 0) {
        sum += num % 10;
        num /= 10;
    }

    return sum;
}

int main() {
    int N, A, B;
    int target = 0;
    int total = 0;

    cin >> N >> A >> B;

    for(int i = 0; i <= N; i++) {
        target = sum_digit(i);
        if(target >= A && target <= B) total += i;
    }

    cout << total << endl;
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
#define PI acos(-1)
using namespace std;
int main(){

  int n,s;
  while(cin>>n>>s,n||s){
    int in[20000]={0};
    int co=0;
    rep(i,n)cin>>in[i];
    rep(i,n){
      rep(j,i){
	if(in[i]+in[j]>s)co++;
      }
    }
    cout<<co<<endl;
  }


}

Measured memory_bytes: 1244
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iterator>
#include <math.h>
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#include <algorithm>
#include <cmath>
using namespace std;
pair<ll,ll> norm(ll a,ll b)
{
  if(a<0)
  {
    a*=-1;
    b*=-1;
  }
  else if ((a==0)&&(b<0))
  {
    b*=-1;
  }
  ll d=__gcd(abs(a),abs(b));
  a=(ll)(a/d);
  b=(ll)(b/d);
  pair <ll,ll> p=mp(a,b);
  return p;
}
bool decreasing(pair<ll,ll> a,pair<ll,ll> b) 
{ 
       if(a.first>b.first)
       return true;
       else if(a.first==b.first)
       {
        if(a.second<b.second)
        return false;
        else
        return true;
       } 
       else
       return false;
} 
ll expo(ll x,ll y) 
{ 
    ll res = 1;  
    while(y>0) 
    {  
        if(y&1) 
        res=(res*x)%1000000007;  
        y=y>>1;
        x=(x*x)%1000000007; 
    } 
    return res; 
}
int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // int T,p;
    // cin>>T;
    // for(p=1;p<=T;p++)
    // {
      ll a,b,c,d,ans=-1e19,i,j,k;
      cin>>a>>b>>c>>d;
      if((b>=0)&&(d>=0))
      {
        i=b*d;
        ans=max(ans,i);
      }
      if((a<=0)&&(c<=0))
      {
        i=a*c;
        ans=max(ans,i);
      }
      if((b<=0)&&(c>=0))
      {
        i=b*c;
        ans=max(i,ans);
      }
      if((b<=0)&&(c<=0))
      {
        i=b*c;
        ans=max(i,ans);
      }
      if(d<=0)
      {
        i=d*a;
        ans=max(i,ans);
      }
      cout<<ans;
      return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std ;
#define ll long long 
#define pb push_back
#define in(x) int x; cin>>x;
#define ln(x) long long x; cin>>x;
#define memf(a) memset(a,false,sizeof(a))
#define F first
#define S second
#define endl "\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
int main()
{
	fast
	int n;
	cin>>n;
	ll a[n],pre=0;
	ll M=1e9+7;
	for(int i=0;i<n;i++) {cin>>a[i];pre+=a[i];}
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		pre-=a[i];
		ll x=((pre%M)*a[i])%M;
		sum+=(x);
		sum%=M;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 5196
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,cos,mini=1e9+7;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=-100;i<101;i++){
        cos=0;
        for(int j=0;j<n;j++){
            cos+=(i-a[j])*(i-a[j]);
        }
        mini=min(cos,mini);
    }
    cout<<mini<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        int n = sc.nextInt();
     	int m = sc.nextInt();
        int count = 0; 
        String a[] = new String[n];
        for(int i = 0;i < n;i++){
          a[i] = sc.next();
        }
        String b[] = new String[m];
        for(int i = 0;i < m;i++){
          b[i] = sc.next();
        }
      
      
      
        for(int i =0;i <= n - m;i++){
          for(int j = 0;j <= n - m;j++){
            count = 0;
            for(int k = 0;k < m;k++){
              if(b[k].equals(a[i + k].substring(j,j+m))){
				count++;
              }
            }
            if(count == m){
              System.out.println("Yes");
              System.exit(0);
            }
          }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 37008
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int s,a[N];
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		s+=a[i];
	}
	if(s%10!=0)printf("%d",s);
	else {
		sort(a+1,a+n+1);
		for(int i=1;i<=n;i++)
			if(a[i]%10!=0){
				s-=a[i];
				break;
			}
		if(s%10!=0)printf("%d",s);
		else puts("0");
	}
	return 0;
}

Measured memory_bytes: 256
N=int(input())
h=list(map(int,input().split()))
ans=[0]*N
for i in range(1,N):
    if i==1:
        ans[i]=abs(h[i]-h[i-1])
    else:
        ans[i]=min(abs(h[i]-h[i-1])+ans[i-1],abs(h[i]-h[i-2])+ans[i-2])
print(ans[N-1])

Measured memory_bytes: 13928
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

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

	ll t1 = 0;
	ll t2 = 0;
	if(k%2==1){
		for(int i=1;i<=n;i++) if(i%k==0) t1++;
	}else{
		for(int i=1;i<=n;i++){
			if(i%k==0) t1++;
			if(i%k==k/2) t2++;
		}
	}
	ans = t1*t1*t1+t2*t2*t2;

	cout << ans << endl;

	return 0;
}

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

#define int long long

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

string s;

signed main() {
    cin >> s;
    if (s.size() % 2 == 1 ^ s[0] == s[s.size() - 1]) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
    return 0;
}


Measured memory_bytes: 512
import sys
N = int(input())

a = [int(n) for n in input().split()]

dic = {}
for ak in a:
    if not(ak in dic):
        dic[ak] = 1
    else:
        dic[ak] += 1
ans = 0
for k in dic.keys():
    if(dic[k] - k > 0):
        ans+=dic[k] - k
    elif(dic[k] - k < 0):
        ans+=dic[k]
print(ans)


Measured memory_bytes: 18164
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,X,T;



signed main(){
	cin>>N>>X>>T;
	cout<<ceil2(N,X)*T<<endl;
	return 0;
}


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

int main(){
    long long X, cnt = 0, money = 100;
    cin >> X;
    for(;;){
        money = money * 1.01;
        cnt++;
        if(money >= X){
            break;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s;
	cin >> s;

	int n = s.length();
	if (n < 7) {
		cout << "NO" << endl;
		return 0;
	}

	string t = "keyence";
	if (n == 7) {
		if (s == t)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;

		return 0;
	}
	
	for (int i = 0; i <= 7; ++i) {
		string tmp = s.substr(0, i) + s.substr(n-7+i);
		if (tmp == t) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 384
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    s = input().rstrip()
    res = 0
    for k,v in groupby(list(s)):
        res += 1
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 49392
#include <string>
#include <iostream>
#include <map>
#define llint long long

using namespace std;

llint n;
llint a[1005];
map<llint, llint> mp;

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j*j <= a[i]; j++){
			if(a[i] % j == 0){
				mp[j] += a[i];
				if(j*j != a[i]) mp[a[i]/j] += a[i];
			}
		}
	}
	llint ans = 0;
	for(auto it = mp.begin(); it != mp.end(); it++){
		if(it->first == 1) continue;
		//cout << it->first << " " << it->second << endl;
		ans = max(ans, it->second);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 4440
#coding:utf-8

d,g = map(int, input().split())
P = []
C = []
sums = []
for i in range(d):
    p,c = map(int, input().split())
    P.append(p)
    C.append(c)
    sums.append(p * 100 * (i+1) + c)

ans = 1e9
for mask in range(1 << d):
    score = 0
    num = 0
    rest_max = -1
    for i in range(d):
        if mask >> i & 1:
            score += sums[i]
            num += P[i]
        else:
            rest_max = i
    if score < g:
        tmp = 100 * (rest_max + 1)
        need = (g - score + tmp - 1) // tmp
        if need >= P[rest_max]: continue
        num += need
    ans = min(ans, num)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K,S;
  cin >> K >> S;
  int res =0;
  for (int x=0; x<K+1 ; x++ ){
    for(int y=0; y < K+1; y++ ){
      if(S-x-y <= K && S-x-y>=0){
        res +=1;
      }
    }
  }
  cout << res <<endl;
}

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

int main(){
  int n, m, q; cin >> n >> m >> q;
  int seg[n][n];
  rep(i, n)rep(j, n) seg[i][j] = 0;
  rep(i, m){
    int l, r; cin >> l >> r;
    seg[l-1][r-1]++;
  }
  rep(i, n){
    int cur = 0;
    rep(j, n){
      cur += seg[i][j];
      seg[i][j] = cur;
    }
  }
  rep(i, n){
    int cur = 0;
    rep(j, n){
      cur += seg[n-j-1][i];
      seg[n-j-1][i] = cur;
    }
  }
  rep(i, q){
    int p, q; cin >> p >> q;
    cout << seg[p-1][q-1] << endl;
  }
}

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <array>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
#include <random>
#include <ctime>
#include <algorithm>
#include <functional>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <climits>
#include <utility>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << setprecision(10) << fixed;
	/////////////////////////////////////////////////////////////
	string s, t, temp;
	cin >> s >> t;
	for (int i = 0; i < s.length(); ++i) {
		temp = s[s.length() - 1] + s.substr(0, s.length() - 1);
		s = temp;
		if (s == t) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	/////////////////////////////////////////////////////////////
	cout << "\n";
	return 0;
}
/*
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout << setprecision(10) << fixed;
/////////////////////////////////////////////////////////////
string s, t, temp;
cin >> s >> t;
for (int i = 0; i < s.length(); ++i) {
temp = s[s.length() - 1];
s.erase(s.length() - 1, 1);
temp += s;
s = temp;
if (s == t) {
cout << "Yes\n";
return 0;
}
}
cout << "No\n";
/////////////////////////////////////////////////////////////
cout << "\n";
return 0;
}
*/

Measured memory_bytes: 256