akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 100002;
string t;
ll ans=700;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>t;
	FOR(i,0,3)if(t[i]=='o')ans+=100;
	pri(ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int l,a,b,c,d,k,s;
	scanf("%d %d %d %d %d",&l,&a,&b,&c,&d);
	k=a/c;
	if(a%c!=0){
		k++;
	}
	s=b/d;
	if(b%d!=0){
		s++;
	}
	if(k>s){
		printf("%d\n",l-k);
	}
	else{
		printf("%d\n",l-s);
	}
	return 0;
}


Measured memory_bytes: 2096
#include <iostream>
#include <cstdio>
#include <cstring>
#define mod 998244353
using namespace std;


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

long long dp[2][2003];
char s[2003];

long long fsp(long long base, long long p) {
    long long rt = 1;
    while (p) {
        if (p & 1) (rt *= base) %= mod;
        (base *= base) %= mod;
        p >>= 1;
    }
    return rt;
}

int main() {
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    dp[0][0] = 1;
    int t = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= i; ++j) dp[t ^ 1][j] = 0;
        for (int j = 0; j <= i - 1; ++j) {
            if (s[i] == '0') {
                (dp[t ^ 1][j + 1] += dp[t][j]) %= mod;
                if (j != i - 1) (dp[t ^ 1][j + 2] += dp[t][j]) %= mod;
            }
            if (s[i] == '1') {
                (dp[t ^ 1][j + 1] += dp[t][j]) %= mod;
                (dp[t ^ 1][j] += dp[t][j]) %= mod;
            }
            if (s[i] == '2') {
                (dp[t ^ 1][j] += dp[t][j]) %= mod;
                if (j != 0) (dp[t ^ 1][j - 1] += dp[t][j]) %= mod;
            }
        }
        t ^= 1;
    }
    long long res = 0, tmp = 1;
    for (int i = 0; i <= n; ++i) {
        (res += tmp * dp[t][i] % mod) %= mod;
        (tmp *= fsp(i + 1, mod - 2) * (long long)(n - i) % mod) %= mod;
    }
    printf("%lld", res);
    return 0;
}

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

const int INF=2000000000; 

int cnt;

void merge(int *A,int l,int mid,int r){
    int n1=mid-l;
    int n2=r-mid;
    int L[n1+1],R[n2+1];
    for(int i=0;i<n1;i++) L[i]=A[l+i];
    for(int i=0;i<n2;i++) R[i]=A[mid +i];
    L[n1]=INF;
    R[n2]=INF;
    int i=0,j=0;
    for(int k=l;k<r;k++){
        cnt++;
        if(L[i]<=R[j]) A[k]=L[i++];
        else A[k]=R[j++];
    }
}

void mergesort(int *A,int l,int r){
    if(l+1<r){
        int mid=(l+r)/2;
        mergesort(A,l,mid);
        mergesort(A,mid,r);
        merge(A,l,mid,r);
    }
}

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    mergesort(a,0,n);
    for(int i=0;i<n;i++){
        cout<<a[i];
        if(i!=n-1)cout<<' ';
        else cout<<endl;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 6920
N = input().strip()
n = len(N)
cntmax = 0
for i in range(n):
    cntmax += int(N[i])
for j in range(n-1):
    x=N[:j]
    if N[j]!="0":
        x += str(int(N[j])-1)+"9"*(n-1-j)
        cnt = 0
        for i in range(n):
            cnt += int(x[i])
        cntmax = max(cntmax,cnt)
print(cntmax)       

Measured memory_bytes: 38256
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

saisyou = min([A,B,C,D,E])
if N%saisyou ==0:
    print(N//saisyou +4)
else:
    print(N//saisyou +5)

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

using namespace std;

#define endl "\n"
#define lln long long unsigned int
#define IOS ios::sync_with_stdio(0);cin.tie(0);

vector<int> visited;
vector<vector<int>> adj;
int ans=0;

const lln MOD = 1e9 + 7;

void dfs(int u){
    visited[u] = 1;
    ans++;
    for(auto i : adj[u]){
        if(!visited[i]) dfs(i);
    }
}

int main(){
    IOS;

    int n,m;
    cin >> n >> m;
    visited = vector<int> (n+1);
    adj = vector<vector<int>> (n+1);
    for(int i=0,x,y;i<m;i++){
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    int ma = 0;
    for(int i=1;i<=n;i++){
        if(!visited[i]) dfs(i);
        ma = max(ma,ans);
        ans = 0;
    }
    cout << ma << endl;
    return 0;    
}

Measured memory_bytes: 21108
ary = gets.chomp.split.map(&:to_i) #n xの入力
minimum = ary[1]
# ｘをmiの最大値として入力
sum = 0
ary[0].times do |i|
  tmp = gets.to_i
  sum += tmp
  minimum = tmp if tmp<minimum
end
puts((ary[1]-sum)/minimum+ary[0])


Measured memory_bytes: 1788
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    Block[] blocks = new Block[N];
    for (int i = 0; i < N; i++) {
      blocks[i] = new Block(scanner.nextInt(), scanner.nextInt(), scanner.nextInt());
    }

    Arrays.sort(blocks, Comparator.comparingInt(b -> b.s + b.w));

    final int MAX_W = 20_000;
    long[] dp = new long[MAX_W + 1];
    for (int i = 1; i <= N; i++) {
      Block b = blocks[i - 1];
      for (int j = b.s; j >= 0; j--) {
        dp[j + b.w] = Math.max(dp[j] + b.v, dp[j + b.w]);
      }
    }

    long max = 0;
    for (int i = 0; i <= MAX_W; i++) {
      max = Math.max(max, dp[i]);
    }
    System.out.println(max);
  }

  private static class Block {
    public final int w;
    public final int s;
    public final int v;

    private Block(int w, int s, int v) {
      this.w = w;
      this.s = s;
      this.v = v;
    }
  }
}


Measured memory_bytes: 30924
#include<bits/stdc++.h>
using namespace std;
static const int64_t INF=10000000000000;
static const int64_t zero=0;
int64_t N,K;
int64_t dp[305][305][305];
int main(){
  for(int i=0;i<305;i++)
    for(int j=0;j<305;j++)
      for(int k=0;k<305;k++)
        dp[i][j][k]=INF;
  cin>>N>>K;
  vector<int64_t>H(N+1);H[0]=0;
  for(int i=1;i<=N;i++)
    cin>>H.at(i);
  dp[0][0][0]=0;
  for(int i=1;i<=N;i++)
    dp[i][i][0]=dp[i-1][i-1][0]+max(zero,H[i]-H[i-1]);
    for(int i=1;i<=N;i++)
      for(int j=0;j<=i;j++)
      for(int k=1;k<=K;k++){
      if(i!=j){
      dp[i][j][k]=dp[i-1][j][k-1];
      }else{
        int64_t a=INF;
        for(int l=0;l<=i-1;l++)
         if(0<=k-i+1+l){
      if(dp[l][l][k-i+1+l]+max(zero,H[i]-H[l])<a)
        a=dp[l][l][k-i+1+l]+max(zero,H[i]-H[l]);
      }
     dp[i][i][k]=a;
    }
      
      }int64_t ans=INF;
         for(int j=0;j<=N;j++){
         if(dp[N][j][K]<ans)ans=dp[N][j][K];
         }cout<<ans<<endl;
  return 0;
}

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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define REP(i,n) for(int i=0; i < (n); ++i)
#define SIZE(c) (int) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define PB push_back
#define MP make_pair
#define ST first
#define ND second
#define FWD(i,a,b) for (int i=(a); i<(b); ++i)
#define BCK(i,a,b) for (int i=(a); i>(b); --i)
#define PI 3.14159265358979311600
#define pb push_back
#define mp make_pair
#define st first
#define nd second

using namespace std;

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

typedef vector < int > VI;
typedef vector<ll> VL;

typedef long double K;

int cur = 1;

deque<int> go(long long n) {
	deque<int> result;
	if (n == 0) {
		return result;
	}
	if (n % 2) {
		result = go(n / 2);
		result.insert(result.begin() + SIZE(result)/2, cur);
		result.push_back(cur);
		++cur;
		return result;
	}
	result = go(n - 1);
	result.push_front(cur);
	result.push_back(cur);
	++cur;
	return result;
}

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

	long long n;
	cin >> n;

	auto result = go(n);

	cout << (int)result.size() << '\n';

	for (auto& item : result) {
		cout << item << ' ';
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cctype>
#include<vector>
#include<map>
#include<set>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
#define pb push_back
#define mid (l+r>>1)

using namespace std;
const int N=200005;
int n,x,y,tot,head,tail,c[N],dis;
struct data
{
	int x,y;
	bool operator < (const data &t) const
	{
		return x<t.x || x==t.x && y<t.y;
	}
} dat[N],q[N];
vector <int> vt[N];
map <int,int> id0,id1;
map <data,int> mp;
map <data,bool> vis;
set <data> st[N];
typedef set <data> :: iterator it;
typedef long long LL;
LL ans;

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

int get(int x,int y)
{
	return abs(dat[x].x-dat[y].x)+abs(dat[x].y-dat[y].y);
}

int findr(int p,int x)
{
	int l=0,r=vt[p].size()-1;
	while(l<=r) vt[p][mid]>=x?r=mid-1:l=mid+1;
	return r+1;
}

int findl(int p,int x)
{
	int l=0,r=vt[p].size()-1;
	while(l<=r) vt[p][mid]<=x?l=mid+1:r=mid-1;
	return l-1;
}

int query(int x,int l,int r)
{
	if(!x) return 0;
	return findl(x,r)-findr(x,l)+1;
}

int query(int x,int y)
{
	int ret=0;
	ret-=mp.count((data){x-dis,y});
	ret-=mp.count((data){x+dis,y});
	ret-=mp.count((data){x,y-dis});
	ret-=mp.count((data){x,y+dis});

	ret+=query(id0[x-dis+y],x-dis,x);
	ret+=query(id1[x-dis-y],x-dis,x);
	ret+=query(id0[x+dis+y],x,x+dis);
	ret+=query(id1[x+dis-y],x,x+dis);
	return ret;
}

void pushup(data x)
{
	if(vis.count(x)) return;
	vis[x]=1,q[++tail]=x;
}

void bfs()
{
	tail=-1,pushup(dat[x]);
	while(head<=tail)
	{
		int u=q[head].x,v=q[head].y;
		++head;
		int id=id0[u-dis+v];
		for(it p=st[id].lower_bound((data){u-dis,0}); p!=st[id].end() && p->x<=u; )
		{
			data tmp=*p;
			pushup(tmp),++p,st[id].erase(tmp);
		}
		
		id=id1[u-dis-v];
		for(it p=st[id].lower_bound((data){u-dis,0}); p!=st[id].end() && p->x<=u; )
		{
			data tmp=*p;
			pushup(tmp),++p,st[id].erase(tmp);
		}

		id=id0[u+dis+v];
		for(it p=st[id].lower_bound((data){u,0}); p!=st[id].end() && p->x<=u+dis; )
		{
			data tmp=*p;
			pushup(tmp),++p,st[id].erase(tmp);
		}

		id=id1[u+dis-v];
		for(it p=st[id].lower_bound((data){u,0}); p!=st[id].end() && p->x<=u+dis; )
		{
			data tmp=*p;
			pushup(tmp),++p,st[id].erase(tmp);
		}
	}
}

int main()
{
	n=getint(),x=getint(),y=getint();
	rep(i,1,n)
	{
		int u=dat[i].x=getint(),v=dat[i].y=getint();
		mp[dat[i]]=i;
		if(!id0.count(u+v)) id0[u+v]=++tot;
		if(!id1.count(u-v)) id1[u-v]=++tot;
		st[id0[u+v]].insert(dat[i]);
		vt[id0[u+v]].pb(u);
		st[id1[u-v]].insert(dat[i]);
		vt[id1[u-v]].pb(u);
	}
	dis=get(x,y);
	rep(i,1,tot) sort(vt[i].begin(),vt[i].end());
	rep(i,1,n) c[i]=query(dat[i].x,dat[i].y);
	bfs();
	rep(i,0,tail)
		ans+=c[mp[q[i]]];
	printf("%lld\n",ans/2);
	return 0;
}
	

Measured memory_bytes: 61440
h,w,m = gets.split.map(&:to_i)
tate = Array.new(h,0)
yoko = Array.new(w,0)
z = Array.new(0)

for i in 0...m
  temp = gets.split.map(&:to_i)
  temp[0]-=1
  temp[1]-=1
  tate[temp[0]] += 1
  yoko[temp[1]] += 1
  z.push temp
end

tate1 = Array.new(0)
yoko1 = Array.new(0)

max_tate = tate.max
max_yoko = yoko.max

for i in 0...h
  if max_tate==tate[i]
    tate1.push i
  end
end
for i in 0...w
  if max_yoko==yoko[i]
    yoko1.push i
  end
end

cnt = 0
for i in 0...m
  if tate[z[i][0]]==max_tate && yoko[z[i][1]]==max_yoko
    cnt += 1
  end
end

if tate1.size*yoko1.size>cnt
  puts max_tate+max_yoko
else
  puts max_tate+max_yoko-1
end

Measured memory_bytes: 43972
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
#define int long long
signed main(){
	ic(n)
	if(n<2000){
		if(n/100*5<n%100){
			c(0)
			return 0;
		}
	}
	c(1)		
}	

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}


fn main() {
  let n: usize = read();
  let mut current_min = std::i32::MAX;
  let mut ans = std::i32::MIN;

  for i in 0..n {
    let x: i32 = read();
    if x - current_min > ans { ans = x - current_min };
    if x < current_min { current_min = x };
  }

  println!("{}", ans);
}



Measured memory_bytes: 5044
def main():
    n = int(input())
    a_list = list(map(int,input().split()))

    cnt =  1
    flag = False
    for i in a_list:
        if i == cnt:
            cnt+=1
            flag = True
            continue

    ans = n - cnt + 1
    if not flag:
        ans = -1
    print(ans)

main()


Measured memory_bytes: 24744
long long d[21];
v,i,j;
main(n){
	scanf("%d%d",&n,&v);
	d[v]=1;
	for(i=0;i<n-2;i++){
		long long e[21]={0};
		scanf("%d",&v);
		for(j=0;j<=20;j++){
			if(j+v<=20)
				e[j+v]+=d[j];
			if(j-v>=0)
				e[j-v]+=d[j];
		}
		memcpy(d,e,sizeof(d));
	}
	scanf("%d",&v);
	v=!printf("%lld\n",d[v]);
}

Measured memory_bytes: 0
/**
 * @author      : omgursocute
 * @file        : 130/C.cpp
 * @created     : 29/12/2019
 */

#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	ll w, h, x, y;
	cin >> w >> h >> x >> y;

	ld d = (ld)w*(ld)h/2;
	cout << d << ' ' << (x+x == w && y+y == h);
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
//double pi=3.1415926535898;
//double pi=acos(-1.0);
#define scarr(a,s,e) for(int i=s;i<=int(e);i++) scanf("%d ",&a[i]);
#define prarr(a,s,e) for(int i=s;i<=int(e);i++) printf("%d ",a[i]);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define mkp        make_pair
#define sc(x)      scanf("%d",&x)
#define scl(x)     scanf("%lld",&x)
#define pr(x)      printf("%d ",x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define prlln(x)   printf("%lld\n",x)
#define r0         return 0;
#define CC         continue;
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x)
#define bb(x)      cerr<< x <<endl;
#define pii        pair<int,int>
#define pis        pair<int,string>
#define vi         vector<int>
#define x         first
#define y         second
//#define max(a,b) a<b?b:a
//#define min(a,b) a<b?a:b
const ll M  = 1e9+7 ;
const ll linf = 1e18 ;
const int iinf = INT_MAX ;
const int N = 300300 ;
//////////////////////    Hi    ^_^  hack me if you can :P

int  main()
{
int a,b,c;
cin>>a>>b>>c;
if(a==b+c||
   b==a+c||
   c==a+b){
    cout<<"Yes";
   }
   else
    cout<<"No";
}

/*

ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}
Wj0944296025*
*/
/*
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);
for (int i=0;i<n;i++)            Hi    ^_^  hack me if you can :P
int mx[]= {0,0,1,-1, 1,1,-1,-1};
int my[]= {1,-1,0,0, 1,-1,1,-1};
bool inside (int i,int j) {return (i>=0 && i<n && j>=0 && j<m);}

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void gcd(LL n,LL m,LL &d,LL &xx,LL &yy){
    if(!m) {d=n; xx=1; yy=0;}
    else {gcd(m,n%m,d,yy,xx); yy-=xx*(n/m);}
}

int getm(int l,int r)
{
    if(l>r)
        return N;
    if(l==r)
        return 0;
    if(l==r-1)
        return s[l] != s[r];
    if(s[l]==s[r])
        return getm(l+1,r-1);
    else
        return 1+min(getm(l+1,r),getm(l,r-1));
}

int BIT[si], a[si], n;
void update(int x, int delta)
{
    for(; x <= N; x += x&-x)
        BIT[x] += delta;
}
int query(int x)
{
    int sum = 0;
    for(; x > 0; x -= x&-x)
        sum += BIT[x];
    return sum;
}

*/


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scan_init()
	n := scan()
	s := strings.Split(n,"")
	count := 0
	flag := false
	for i:= 0; i<3; i++ {
		if s[i] == "R" {
			flag = true
		} else if flag{
			break
		}
		if flag {
			count ++
		}
	}
	fmt.Println(count)

}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 200000)

func readLine() string {
	buf := make([]byte, 0, 200000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
func readLineToNumber() int {
	S := readLine()
	number, _ := strconv.Atoi(S)
	return number
}
func readLineToSlice() []string {
	S := readLine()
	list := strings.Split(S, "")
	return list
}
func readLineToNumberSlice(memo map[string]int) []int {
	// err時は-1を代入
	S := readLine()
	intList := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		if val, ok := memo[string(S[i])]; ok {
			intList[i] = val
		} else {
			intList[i] = -1
		}
	}
	return intList
}

Measured memory_bytes: 1788
n = int(input())
t,a = map(int,input().split())
l = []
m = []
ans = []

l = list(map(int,input().split()))
    
for i in range(n):
    m.append(t - (l[i] * 0.006))

for i in range(n):
    ans.append(a - m[i])

print(ans.index(min(ans,key=abs))+1)

Measured memory_bytes: 38696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Reader.init(System.in);
		int nReq = Reader.nextInt();
		int len = Reader.nextInt();
		int cntB[][] = new int[len][len];
		int cntW[][] = new int[len][len];
		for(int i = 0; i < nReq; i++) {
			int x = Reader.nextInt();
			int y = Reader.nextInt();
			char ch = Reader.next().charAt(0);
			int rx = (x / len) % 2;
			int ry = (y / len) % 2;
			if( (ch == 'B' && (rx + ry) % 2 == 0) ||
				(ch == 'W' && (rx + ry) % 2 == 1) ){
				cntB[x % len][y % len]++;
			}
			else if( (ch == 'W' && (rx + ry) % 2 == 0) || 
					 (ch == 'B' && (rx + ry) % 2 == 1) ){
				cntW[x % len][y % len]++;
			}
		}

		int[][] sumW = new int[len][len];
		int[][] sumB = new int[len][len];
		for(int i = 0; i < len; i++) {
			for(int j = 0; j < len; j++) {
				sumW[i][j] = (i == 0 ? 0 : sumW[i - 1][j]) + 
						(j == 0 ? 0 : sumW[i][j - 1]) - 
						( (i == 0 || j == 0) ? 0 : sumW[i - 1][j - 1]) + 
						cntW[i][j];
				sumB[i][j] = (i == 0 ? 0 : sumB[i - 1][j]) + 
						(j == 0 ? 0 : sumB[i][j - 1]) - 
						( (i == 0 || j == 0) ? 0 : sumB[i - 1][j - 1]) + 
						cntB[i][j];
			}
		}

		int ans = 0;
		for(int i = 0; i < len; i++) {
			for(int j = 0; j < len; j++) {
				int amo = 0;
				amo = (sumB[i][j] + sumB[len - 1][len - 1] - sumB[i][len - 1] - sumB[len - 1][j] + sumB[i][j]) +
						(sumW[i][len - 1] + sumW[len - 1][j] - 2 * sumW[i][j]);
				if(amo > ans)
					ans = amo;
				amo = (sumW[i][j] + sumW[len - 1][len - 1] - sumW[i][len - 1] - sumW[len - 1][j] + sumW[i][j]) +
						(sumB[i][len - 1] + sumB[len - 1][j] - 2 * sumB[i][j]);
				if(amo > ans)
					ans = amo;
			}
		}
		System.out.println(ans);
	}

}

/** Class for buffered reading int and double values */
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    public static void main(String[] args) {
    	
    }
}

Measured memory_bytes: 54356
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()
using namespace std;
using P = pair<int, int>;
typedef long long ll;

int a[12][12];

const int INF = 1001001001;

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	rep(i, n)
	{
		cin >> c[i];
		rep(j, m) cin >> a[i][j];
	}

	int ans = INF;
	rep(s, 1<<n)
	{
		int cost = 0;
		vector<int> d(m);
		rep(i, n)
		{
			if (s>>i&1) // sのibit目が立っている
			{
				cost += c[i];
				rep(j, m) d[j] += a[i][j];
			}
		}
		bool ok = true;
		rep(j,m) if (d[j] < x) ok = false; // 1つでもxを満たさないものがあったらfalse
		if (ok) ans = min(ans, cost);
	}
	if (ans == INF) cout << -1 << '\n';
	else cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3660
"use strict";
function main(input) {
  const inputs = input.split("\n").filter(x => x !== "");

  const N = Number(inputs[0]);
  const L = inputs[1].split(" ").map(Number);

  let sL = L.sort((a,b) => a-b);
  let maxL = sL[sL.length - 1];
  let sumL = sL.reduce((acc, cur) => acc + cur);

  // console.log({sL,maxL, sumL})
  console.log(maxL < (sumL - maxL) ? "Yes":"No");

}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define f(a, b, c) for(int a = b; a < c; a++)
#define fr(a, b, c) for(int a = b; a >= c; a--)
using namespace std;


//ll fact[1000001]; ll inv[1000001];
//ll primes[100007];
//ll arr[1000007];
//ll modPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//
//	ll halfpow = modPower(b, p / 2);
//	ll toReturn = (halfpow * halfpow) % mod;
//	if (p % 2)
//		toReturn = (toReturn * b) % mod;
//
//	return toReturn;
//}
//
//ll fastPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//	ll ans = fastPower(b, p / 2);
//	ans = (ans * ans);
//	if (p % 2 != 0)
//		ans = (ans * b);
//	return ans;
//}
//ll GcdRecursive(ll a, ll b) {
//	if (b == 0) return a;
//	return GcdRecursive(b, a % b);
//}
//ll modLCM(ll a, ll b) {
//	ll val = GcdRecursive(a, b);
//	ll tmp = ((a % mod) * (b % mod)) % mod;
//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
//	return finalVal;
//
//}
//ll LCM(ll a, ll b) {
//	return (a * b) / GcdRecursive(a, b);
//}
//void move1step(ll& a, ll& b, ll q) { // a and b by reference
//	ll c = a - q * b;
//	a = b;
//	b = c;
//}
//ll GcdIterative(ll a, ll b) {
//	while (b) move1step(a, b, a / b);
//	return a;
//}
//
//void pre(ll n) {
//
//	fact[0] = 1;
//	inv[0] = 1;
//
//	for (ll i = 1; i <= n; i++) {
//		fact[i] = (i * fact[i - 1]) % mod;
//		inv[i] = modPower(fact[i], mod - 2);
//		arr[i] = modPower(i, mod - 2);
//	}
//}
//
//ll npr(ll n, ll r) {
//	return ((fact[n] * inv[n - r]) % mod);
//}
//
//ll ncr(ll n, ll r) {
//	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
//}
//
//void sieve(ll val) {
//	memset(primes, 1, sizeof primes);
//	primes[0] = primes[1] = false;
//	for (int i = 2; i <= val; i++) {
//		if (primes[i]) {
//			for (int j = i * i; j <= val; j += i) {
//				primes[j] = 0;
//			}
//		}
//	}
//
//}

const ll mod = 1e9 + 7;
const ll N = 2e5 + 7;
const ll inf = 1e9 + 5;



ll n, m, a, b, sum = 0;
vector<ll> adj[N];
bool visited[N] = {false};
ll dp[N] = {};

void dfs(ll node){
    if (visited[node]) return;
    visited[node] = true;

    for (auto child: adj[node]){
        if (!visited[child]) dfs(child);
        dp[node] = max(dp[node] , dp[child] + 1);
        sum = max(sum, dp[node]);
    }
}


int main()
{
    MohamedMotaz;
    cin >> n >> m;
    f(i,0,m) {
        cin >> a >> b; adj[a].push_back(b);
    }
    f(i,1, n + 1){
        dfs(i);
    }




    cout << sum;
}





Measured memory_bytes: 11008
#include <stdio.h>
int main(void){
	int x, y;
	while(1){
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0) break;
		if(x > y){
			printf("%d %d\n", y, x);
		} else {
			printf("%d %d\n", x, y);
		}
	}
	return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;



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

	int cnt = 0;
	for (int i = 0; i < n - 2; i++) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
			cnt++;
		}

	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
    int n;
    ll ryuka[100];
    cin >> n;
    ryuka[0] = 2;ryuka[1] = 1;
    REP(i, 2, n + 1){
        ryuka[i] = ryuka[i - 1] + ryuka[i - 2];
    }
    cout << ryuka[n] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MIN(A,B) \
  ( (A) < (B) ? (A) : (B) )
#define ABS(X) \
  ( (X) < 0 ? -(X) : (X) )

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    int d[ 20 ];
    int sum = 0, res;
    int n;

    scanf ( "%d", &n );
    if ( !n ) break ;

    for ( i = 0; i < n; ++i )
    {
      scanf ( "%d", d + i );
      sum     += d[ i ];
      d[ i ]  *= 2;
    }

    res = sum;
    for ( j = 0; j < ( 1 << n ); ++j )
    {
      int t = sum;

      for ( i = 0; i < n; ++i )
      {
        if ( j & ( 1 << i ) )
        {
          t -= d[ i ];
        }
      }

      res = MIN( res, ABS( t ) );
    }

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

  return ( 0 );
}

Measured memory_bytes: 408
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a % 2 == 1 && b % 2 == 1) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
ll a[55];
map<ll,ll>mp;
ll ncr(ll n,ll r)
{
    ll i,j,s,p,m,l,g;
    s=p=1ll;
    l=max(r,(n-r));
    m=min(r,(n-r));
    for(i=l+1ll,j=2ll; i<=n || j<=m; i++,j++)
    {
        if(i<=n)
        {
            s*=i;
        }
        if(j<=m)
        {
            p*=j;
        }
        g=__gcd(s,p);
        s/=g;
        p/=g;
    }
    s/=p;
    return s;
}
int main()
{
    ft
    ll t,i,j,n,m,l,r,s=0ll,p,q,ans=0ll;
    cin>>n>>l>>r;
    for(i=0ll; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n,greater<ll>());
    m=LLONG_MAX;
    for(i=0ll; i<l; i++)
    {
        m=min(m,a[i]);
        s+=a[i];
        mp[a[i]]++;
    }
    cout<<fixed<<setprecision(6)<<(double)(s*1.0/l)<<"\n";
    p=0ll;
    for(i=0ll; i<n; i++)
    {
        if(a[i]==m)
        {
            p++;
        }
    }
    if(m!=a[0])
    {
        ans+=ncr(p,mp[m]);
    }
    else
    {
        for(i=l-1ll;i<r && a[i]==m;i++)
        {
            ans+=ncr(p,i+1ll);
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
//
// ABC070A
// URL : https://atcoder.jp/contests/abc070/tasks/abc070_a
// 
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

namespace AtCoder
{
    class ABC070A
    {
        static void Main(string[] args)
        {
            preprocess();
            //問題に合わせて適宜必要なものを切り取る

            // 整数の入力
            string n = Console.ReadLine();

            bool ans = false;
            if (n[0] == n[2])
            {
                ans = true;
            }
            else
            {
                ans = false;
            }


            Console.WriteLine( ans ? "Yes" : "No" );
            Console.Out.Flush();
        }

        //---------------------------------------------------------------------------------
        /// <summary>
        /// 
        /// </summary>
        public static void preprocess()
        {
            //出力高速化
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
        }


        /// <summary>
        /// 与えられた数が素数かどうかを計算する
        /// </summary>
        /// <param name="num">対象数</param>
        /// <returns>true:素数, false:素数ではない(合成数)</returns>
        public static bool isPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false;

            double sqrtNum = Math.Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    return false;
                }
            }
            return true;
        }

        /// <summary>
        /// 順列mPnを計算する
        /// </summary>
        /// <param name="m"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static long Permutation(long m, long n)
        {
            long ret = 1;
            for(var i = 0; i < n; ++i)
            {
                ret *= m - i;
            }
            return ret;
        }
        /// <summary>
        /// 組み合わせmCnを計算する
        /// </summary>
        /// <param name="m"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static long Combination(long m, long n)
        {
            if(m == n || n == 0)
            {
                return 1;
            }
            long ans = 1;
            for(var i = 0; i <= n; ++i)
            {
                ans *= (m - i + 1) / i;
            }
            return ans;
        }
    }
}



Measured memory_bytes: 11092
import java.util.*;

public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			char [][] c = new char[n][n];
			for(int i = 0; i < n; i++){
				c[i] = sc.next().toCharArray();
			}
			
			int [][] dp = new int[n][n];
			int max = 0;
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					if(c[i][j] == '*') continue;
					dp[i][j] = 1 << 24;
					if(i - 1 >= 0){
						dp[i][j] = Math.min(dp[i][j], dp[i-1][j]);
					}
					else{
						dp[i][j] = 0;
					}
					if(j - 1 >= 0){
						dp[i][j] = Math.min(dp[i][j], dp[i][j-1]);
					}
					else{
						dp[i][j] = 0;
					}
					
					if(j - 1 >= 0 && i - 1 >= 0){
						dp[i][j] = Math.min(dp[i][j], dp[i-1][j-1]);
					}
					else{
						dp[i][j] = 0;
					}
					if(dp[i][j] == 1 << 24) dp[i][j] = 0;
					dp[i][j]++;
					max = Math.max(dp[i][j], max);
				}
			}
			System.out.println(max);
		}
	}
	
	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 21000
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cerr << v[a][b] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int dp[500100];
int pre[500100];
int nxt[500100];

int main()
{
	int n;
	string str;
	cin >> n >> str;
	str = '0'+ str +'0';n++;
	
	pre[0] = 0;
	nxt[n] = n;
	
	rep(i,1,n)
	{
		if(str[i] == '0')
		{
			pre[i] = i;
		}
		else
		{
			pre[i] = pre[i-1];
		}
	}
	rrep(i,n-1,0)
	{
		if(str[i] == '0')
		{
			nxt[i] = i;
		}
		else
		{
			nxt[i] = nxt[i+1];
		}
	}
	
	
	rep(i,1,n)
	{
		dp[i+1] = max(dp[i],dp[i+1]);
		
		if(str[i] == '1')
		{
			
			if(str[pre[i]-1] == '1')
			{
				int tmp = i - pre[i];
				dp[i+1] = max(dp[pre[i]-1]+tmp,dp[i+1]);
			}
			if(str[nxt[i]+1] == '1')
			{
				int tmp = nxt[i] - i;
				dp[nxt[i]+2] = max(dp[nxt[i]+2],dp[i]+tmp);
			}
		}
	}
	
	//SHOW1d(pre,n+2);
	//SHOW1d(nxt,n+2);	
	//SHOW1d(dp,n+2);
	
	cout << dp[n] << endl;
			
			
			
	
	return 0;
}

Measured memory_bytes: 6680
/*mohammadreza motabar*/
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define pb push_back
typedef pair<int,int> pii;
const ll MAX_N = 60,INF = 1e9;
int a[MAX_N][MAX_N];
char c[MAX_N][MAX_N];
int dx[]={+1,-1,0,0,-1,+1,-1,+1},
    dy[]={0,0,+1,-1,+1,-1,-1,+1};
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m;cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>c[i][j];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			for(int k=0;k<8;k++)
				a[i][j]+=(c[i+dx[k]][j+dy[k]]=='#');
	for(int i=1;i<=n;i++,cout<<"\n")
		for(int j=1;j<=m;j++)
			if(c[i][j]!='#')
				cout<<a[i][j];
			else
				cout<<"#";
}


Measured memory_bytes: 256
import Data.Monoid
import Control.Monad
import Data.List
import Control.Applicative

instance Monoid Int where
    mempty = 2 ^ 31 - 1
    mappend = min

data Segtree m = Leaf {-# UNPACK #-} !m
               | Node
                    {-# UNPACK #-} !(Segtree m)
                    {-# UNPACK #-} !(Segtree m)
                    {-# UNPACK #-} !m
                    {-# UNPACK #-} !Int
                deriving (Show, Eq)

{-# INLINE size #-}
size :: Monoid m => Segtree m -> Int
size (Leaf _) = 1
size (Node _ _ _ n) = n

{-# INLINE value #-}
value :: Monoid m => Segtree m -> m
value (Leaf x) = x
value (Node _ _ x _) = x

combine :: Monoid m => Segtree m -> Segtree m -> Segtree m
combine lch rch = Node lch rch (value lch <> value rch) (size lch + size rch)

rangeQuery :: Monoid m => Int -> Int -> Segtree m -> m
rangeQuery a b (Leaf x)
    | b <= 0 || a >= 1 = mempty
    | otherwise = x
rangeQuery a b (Node lch rch x n)
    | b <= 0 || a >= n = mempty
    | a <= 0 && n <= b = x
    | otherwise = rangeQuery a b lch <> rangeQuery (a - lsize) (b - lsize) rch
        where lsize = size lch

update :: Monoid m => Int -> m -> Segtree m -> Segtree m
update k x (Leaf _) = Leaf x
update k x (Node lch rch _ _)
    | k < size lch = combine (update k x lch) rch
    | otherwise = combine lch $ update (k - size lch) x rch

build :: Monoid m => Int -> Segtree m
build n
    | n <= 1 = Leaf mempty
    | otherwise = combine (build (n `div` 2)) (build (n - n `div` 2))

processQuery :: Int -> [[Int]] -> [Int]
processQuery n = reverse . snd . foldl' step (build n, [])
    where step (tree, res) [0, x, y] = (update x y tree, res)
          step (tree, res) [_, x, y] = (tree, rangeQuery x (y + 1) tree : res)

splitRead = map read . words <$> getLine

main = do
    [n, q] <- splitRead
    replicateM q splitRead >>= mapM_ print . processQuery n

Measured memory_bytes: 121988
package Dsu;
sub new{
	return bless[(-1)x$_[1]],$_[0];
}
sub merge{
	my$self=shift;
	my$x=$self->leader($_[0]);
	my$y=$self->leader($_[1]);
	return$x if$x==$y;
	($x,$y)=($y,$x)if-$self->[$x]<-$self->[$y];
	$self->[$x]+=$self->[$y];
	return$self->[$y]=$x;
}
sub same{
	my$self=shift;
	return$self->leader($_[0])==$self->leader($_[1]);
}
sub leader{
	my$self=shift;
	my$a=shift;
	return$a if$self->[$a]<0;
	return$self->[$a]=$self->leader($self->[$a]);
}
sub size{
	return-$_[0]->[$_[1]];
}
sub groups{
	#TODO
}
package main;
my($N,$Q)=split$",<>;
my$dsu=Dsu->new($N);
for(1..$Q){
	my($t,$u,$v)=split$",<>;
	if($t==0){
		$dsu->merge($u,$v);
	}
	else{
		print $dsu->same($u,$v)?1:0,$/;
	}
}


Measured memory_bytes: 15008
#!/usr/bin/env python3
import sys
from collections import Counter

def solve(N: int, K: int, A: "List[int]"):
    counter = list(Counter(A).values())
    counter.sort()

    if len(counter) <= K:
        print(0)
    else:
        need = len(counter)-K
        print(sum(counter[:need]))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 43760
#include <cstdio>

int main() {
	int h, w;
	while (1) {
		scanf("%d %d", &h, &w);
		if (!h && !w) break;
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				if ((i > 1 && i < h) && (j > 1 && j < w))
					putchar('.');
				else
					putchar('#');
			}
			puts("");
		}
		puts("");
	}
}

Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

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

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

    if(n.find("7") == string::npos) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


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

const int MOD = (int)1e9+7;

int main(){
	int N,M;
	cin >> N >> M;
	vector<pair<int,int>> ab(M);
	vector<vector<int>> graph(N);
	for(int i=0;i<M;i++){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		ab.at(i)=make_pair(a,b);
		graph.at(a).push_back(b);
		graph.at(b).push_back(a);
	}

	int ans=0;
	for(int i=0;i<M;i++){
		int a=ab.at(i).first;
		int b=ab.at(i).second;
		vector<bool> visited(N,false);
		queue<int> que;
		que.push(0);
		visited.at(0)=true;
		while(!que.empty()){
			int V=que.front();
			que.pop();
			for(int i=0;i<graph.at(V).size();i++){
				int next_V=graph.at(V).at(i);
				if((V==a && next_V==b) || (V==b && next_V==a))	continue;
				if(visited.at(next_V))	continue;
				visited.at(next_V)=true;
				que.push(next_V);
			}
		}
		bool flag=true;
		for(int i=0;i<N;i++)	if(visited.at(i)!=true)	flag=false;
		if(!flag)	ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long l;
typedef string ss;
int main(){
    ss b;
    l a;
    cin>>b>>a;
    for(l i=0;i<(b.size()+a-1)/a;i++){
        cout<<b[i*a];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n, W; cin >> n >> W;
    vector<int> v(n), w(n);
    rep(i, n){
        cin >> v[i] >> w[i];
    }

    arr<int> dp(n+1, vector<int>(W+1, 0));
    FOR(i, 0, n){
        FOR(j, 0, W+1) {
            chmax(dp[i+1][j], dp[i][j]);
            if(j-w[i]>=0) chmax(dp[i+1][j], dp[i][j-w[i]] + v[i]);
        }
        // prarr(dp);
        // pr("");
    }
    pr(dp[n][W]);
    return 0;}


Measured memory_bytes: 6848
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vll a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    V<int> imos(m + 2, 0);
    for (int i = 0; i < n - 1; i++) {
        if (a[i] < a[i + 1]) imos[a[i] + 2]++, imos[a[i + 1] + 1]--;
        else imos[a[i] + 2]++, imos[1]++, imos[a[i + 1] + 1]--;
    }
    for (int i = 0; i < m + 1; i++) imos[i + 1] += imos[i];

    // for (int i = 0; i < imos.size(); i++) cout << imos[i] << (i == imos.size() - 1 ? '\n' : ' ');

    vll acca(m + 1, 0);
    for (int i = 0; i < n - 1; i++) {
        if (a[i] > a[i + 1]) acca[a[i + 1]] += (ll)(m - a[i] + a[i + 1] - 1);
        else acca[a[i + 1]] += (ll)(a[i + 1] - a[i] - 1);
    }
    // DEBUG_VLL(acca)

    // x = 1
    ll ans = 0;
    for (int i = 0; i < n - 1; i++) {
        if (a[i] > a[i + 1]) {
            ans += (ll)(a[i + 1]);
        } else {
            ans += (ll)(a[i + 1] - a[i]);
        }
    }

    ll tmp = ans;

    // x = 2~m
    for (int i = 2; i < m + 1; i++) {
        ans -= imos[i];
        ans += acca[i - 1];
        chmin(tmp, ans);
    }

    cout << tmp << '\n';
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if((a-b == 0)+(a-c == 0)+(b-c == 0)==1){
   cout<<"Yes"<<endl;
  }else{
   cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3604
s = gets.chomp
i = 0
cnt = 0
array = []
while i <= s.length-1
  if s[i] == "A" || s[i] == "C" || s[i] == "G" || s[i] == "T"
    s[i] = "."
    cnt += 1
  else
    s[i] = "#"
    array << cnt
    cnt = 0
  end
  if i == s.length-1
    array << cnt
  end
  i += 1
end

puts array.max

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

#define rep(i,n) for(int i=0; i<n; i++)
const long SENTINEL = 1000000007;
int gCount;

void merge( long a[], int l, int m, int r ){
	int n1 = m - l;
	int n2 = r - m;
	long *arrL = new long[n1+1];
	long *arrR = new long[n2+1];
	for( int i=0; i<n1; i++ ){
		arrL[i] = a[l+i];
	}
	for( int i=0; i<n2; i++ ){
		arrR[i] = a[m+i];
	}
	arrL[n1] = SENTINEL;
	arrR[n2] = SENTINEL;
	int i=0, j=0;
	for( int k=l; k<r; k++ ){
		gCount++;
		if( arrL[i] <= arrR[j] ){
			a[k] = arrL[i++];
		}else{
			a[k] = arrR[j++];
		}
	}
	delete[] arrL;
	delete[] arrR;
}

void mergeSort( long a[], int l, int r ){
	if( l+1 < r ){
		int m = (l+r)/2;
		mergeSort(a, l, m);
		mergeSort(a, m, r);
		merge(a, l, m, r);
	}
}

int main(){
	int n;
	long s[500000];
	gCount = 0;
	cin >> n;
	rep(i,n) cin >> s[i];
	mergeSort(s,0,n);
	cout << s[0];
	for(int i=1; i<n; i++ )
		cout << " " << s[i];
	cout << endl;
	cout << gCount << endl;
	return 0;
}

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

bool judge(string s1, string s2) {
	for (int i = 0; i < s1.size(); i++) {
		if (s1[i] < s2[i]) {
			return true;
		} else if (s1[i] > s2[i]) {
			return false;
		}
	}
	return false;
}
int main(void) {
	int N, L;
	scanf("%d %d", &N, &L);
	string S[100];
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < N - 1; i++) {
		for (int j = 0; j < N - i - 1; j++) {
			// cout << i << " " << j << "\n";
			// cout << S[j] << " " << S[j + 1] << "\n";
			if (!judge(S[j], S[j + 1])) swap(S[j], S[j + 1]);
		}
	}
	for (int i = 0; i < N; i++) {
		cout << S[i];
	}
	cout << "\n";
	return 0;

}


Measured memory_bytes: 3632
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <cstdio>
#include <time.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <math.h>
#define ll long long
#define int64 long long
#define ull unsigned long long
#define pb push_back
#define INF 0x3f3f3f3f3f3f3f3f
#define lson l, mid, rt<<1
#define rson mid+1, r, rt<<1|1
#define pi 3.141592653589793238462

using namespace std;

const int maxn = 1e5 + 5;
const int maxm = 2e6 + 5;
const int mod = 1e9 + 7;
const int seed = 10007;
const double eps = 1e-5;
int n, x, y, z;
typedef pair<int, int> node;
node a[maxn];
ll b[maxn];
priority_queue<int, vector<int>, greater<int> > q;

bool cmp(node & a, node & b) {
    return a.first - a.second < b.first - b.second;
}

int main() {
    scanf("%d%d%d", &x, &y, &z);
    n = x + y + z;
    ll cnt = 0;
    int c;
    for (int i = 1; i <= n; i++) {
        scanf("%d%d%d", &a[i].first, &a[i].second, &c);
        cnt += c;
        a[i].first -= c, a[i].second -= c;
    }
    sort(a + 1, a + n + 1, cmp);
    ll sum = 0;
    for (int i = 1; i <= n; i++) {
        if (q.size() < y) q.push(a[i].second), sum += a[i].second;
        else if (q.top() < a[i].second) sum -= q.top(), q.pop(), q.push(a[i].second), sum += a[i].second;
        b[i] = sum;
    }
    sum = 0;
    while (!q.empty()) q.pop();
    ll ans = -INF;
    for (int i = n; i > 0; i--) {
        if (q.size() < x) q.push(a[i].first), sum += a[i].first;
        else if (q.top() < a[i].first) sum -= q.top(), q.pop(), q.push(a[i].first), sum += a[i].first;
        if (i > y && q.size() == x) ans = max(ans, b[i - 1] + sum);
    }
    printf("%lld\n", ans + cnt);
    return 0;
}


Measured memory_bytes: 2428