akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

using Value = tuple<int, int>;
static const int MAX_N = 2000010;
static Value heap[MAX_N];
static int sz = 0;
struct BinaryHeap {
	void push(Value x) {
		int v = sz++;
		while (v > 0) {
			int p = (v - 1) / 2;
			if (heap[p] >= x)break;
			heap[v] = heap[p];
			v = p;
		}
		heap[v] = x;
	}
	const Value pop() {
		Value ret = heap[0];
		Value back = heap[--sz];
		int v = 0;
		while (v * 2 + 1 < sz) {
			// l ??¨ r ??????????°???????????????¨???????????????
			int l = v * 2 + 1, r = v * 2 + 2;
			int u = (r >= sz || heap[l] > heap[r]) ? l : r;
			// ???????????¢???????????????
			if (heap[u] <= back)break;
			heap[v] = heap[u];
			v = u;
		}
		heap[v] = back;
		return ret;
	}
	const Value top() {
		return heap[0];
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; scanf("%d%d", &n, &q);
	vector<int> a(q), v(q); rep(i, 0, q) {
		scanf("%d%d", &a[i], &v[i]);
		a[i]--;
	}
	BinaryHeap pq;
	using T = Value;
	rep(i, 0, n)pq.push(T(0, -i));
	vector<int> point(n);
	rep(i, 0, q) {
		point[a[i]] += v[i];
		pq.push(T(point[a[i]], -a[i]));
		while (true) {
			int p, u; tie(p, u) = pq.top(); pq.pop();
			if (point[-u] != p)continue;
			printf("%d %d\n", -u + 1, p);
			pq.push(T(p, u));
			break;
		}
	}
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

int main() {
   int n,p;cin >>n>>p;
   ll odd=0,even=0;
    for (int i = 0; i < n; ++i) {
        int a;cin >>a;
        if(a%2==0){
            even++;
        }
        else {
            odd++;
        }
    }
    if(odd==0&&p==1){
        cout <<0<<endl;
        return 0;
    }
    ll ans=pow(2,n-1);
    if(odd==0){
        ans=pow(2,n);
    }
    cout <<ans<<endl;
}


Measured memory_bytes: 3888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tmp = Console.ReadLine().Split(' ');
            decimal N = decimal.Parse(tmp[0]);
            decimal M = decimal.Parse(tmp[1]);

            if (Math.Abs(N - M) >= 2)
            {
                Console.WriteLine(0);
                return;
            }
            decimal ansN = kaijou(N) % 1000000007;
            decimal ansM = kaijou(M) % 1000000007;
            decimal ans = 0;
            if (N == M) ans = (ansN * ansM * 2) % 1000000007;
            else ans = (ansN * ansM) % 1000000007;
            Console.WriteLine(ans);
            Console.Read();
        }

        static decimal kaijou(decimal n)
        {
            decimal ret = 1;
            do
            {
                if (n != 1)
                {
                    ret *= n;
                    ret %= 1000000007;
                }
                else
                {
                    break;
                }
                n--;
            } while (true);
            return ret;
        }
    }
}


Measured memory_bytes: 13268
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//符号反転
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(int n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
int main(){
ll n,k;
init();
cin>>n>>k;
ll m=min(n,k+1);
mint ans=1;
for(int i=1;i<m;i++){
	ans+=COM(n,i)*COM(n-1,n-i-1);
}
cout<<ans<<endl;
}

Measured memory_bytes: 47104
// 2011/06/04 Tazoe

#include <iostream>
using namespace std;

void eratos(bool prime[], int n)
{
	if(n>=1)
		prime[0] = false;
	if(n>=2)
		prime[1] = false;

	for(int i=2; i<n; i++)
		prime[i] = true;

	for(int i=2; i<n; i++){
		if(!prime[i])
			continue;
		for(int j=i+i; j<n; j+=i)
			prime[j] = false;
		if(n<i*i)
			return;
	}
}

int main()
{
	bool prime[1000000];
	eratos(prime, 1000000);

	while(true){
		int n;
		cin >> n;
		if(cin.eof())
			break;

		int cnt = 0;
		for(int i=0; i<=n; i++)
			if(prime[i])
				cnt++;

		cout << cnt << endl;
	}

	return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,a,b; cin >> n >> a >> b;
  string s; cin >> s;
  int ca=0,cb=0;
  for(auto e:s){
    if(e == 'a'){
      if(ca+cb < a+b){
	cout << "Yes" << endl;
	ca++;
      } else {
	cout << "No" << endl;
      }
    } else if(e == 'b'){
      if(ca+cb < a+b && cb < b){
	cout << "Yes" << endl;
	cb++;
      } else {
	cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 3744
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	return 0;
}


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

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

using namespace std;

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  rep(i, n) std::cin >> a[i];

  int64_t sum = abs(a[0]);
  for (int i = 0; i < n - 1; ++i) {
    sum += abs(a[i] - a[i + 1]);
  }
  sum += abs(a[n - 1]);

  std::cout << sum - abs(a[0] - a[1]) - abs(a[0]) + abs(a[1]) << std::endl;

  for (int i = 1; i < n - 1; i++) {
    int64_t ans = sum - abs(a[i] - a[i + 1]) - abs(a[i - 1] - a[i]) +
                  abs(a[i - 1] - a[i + 1]);

    std::cout << ans << std::endl;
  }

  std::cout << sum - abs(a[n - 2] - a[n - 1]) - abs(a[n - 1]) + abs(a[n - 2])
            << std::endl;

  return 0;
}


Measured memory_bytes: 3752
//  LINK ZADATKA: http://arc085.contest.atcoder.jp/tasks/arc085_a

#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <complex>
#include <fstream>
#include <cstring>
#include <string>
#include <climits>

using namespace std;

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define INF 999999999
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define _gcd __gcd
#define eps 1e-9

ll n, k, m, sol;
int main(){
	
	slld(n); slld(k);
	
	m = n-k;
	
	sol = k*1900+m*100;

	ll pot2 = 1;
	while(k--) pot2*=2; 
	//printf("%d", pot2);
	sol *= pot2;
	printf("%lld\n", sol);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define MOD2 1000000009
#define sp fixed<<setprecision
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
ll fpow(ll x,ll y,ll p=MOD){x=x%p;ll sum=1;while(y){if(y&1)sum=sum*x;sum%=p;y=y>>1;x=x*x;x%=p;}return sum;}
ll inv(ll a,ll m=MOD){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
ll add(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return (a%MOD + b%MOD + MOD)%MOD;}
ll sub(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return (a%MOD - b%MOD + MOD)%MOD;}
ll mul(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return ((a%MOD)*(b%MOD) + MOD)%MOD;}
void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (sz(name)) {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}
ll h,w;
bool safe(ll x, ll y){
  if(x>=0 && x<h && y>=0 && y<w)
    return true;
  else
    return false;
}
ll dist[1000][1000];
ll dx[4]={0,0,-1,1};
ll dy[4]={1,-1,0,0};
int main(){
    setIO();
    ll xs,ys,xd,yd;
    cin>>h>>w;
    cin>>xs>>ys;
    cin>>xd>>yd;
    xs--;ys--;xd--;yd--;
    char mat[h][w];
    for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      cin>>mat[i][j];

    for(int i=0;i<1000;i++)
    for(int j=0;j<1000;j++)
      dist[i][j]=INT_MAX;

    deque<pair<ll,ll> >q;
    dist[xs][ys]=0;
    q.push_back({xs,ys});
    while(!q.empty()){
      pair<ll,ll>tmp=q.front();
      q.pop_front();
      for(int i=0;i<4;i++){
          ll xx = tmp.f+dx[i];
          ll yy = tmp.se+dy[i];
          if(safe(xx,yy) && mat[xx][yy]=='.'){
            if(dist[xx][yy]>(dist[tmp.f][tmp.se])){
              dist[xx][yy]=dist[tmp.f][tmp.se];
              q.push_front({xx,yy});
            }
          }
      }

      for(int i=-2;i<=2;i++){
        for(int j=-2;j<=2;j++){
          ll xx = tmp.f+i;
          ll yy = tmp.se+j;
          if(safe(xx,yy) && mat[xx][yy]=='.'){
            if(dist[xx][yy]>(dist[tmp.f][tmp.se]+1)){
              dist[xx][yy]=dist[tmp.f][tmp.se]+1;
              q.push_back({xx,yy});
            }
          }
        }
      }

    }
    if(dist[xd][yd]==INT_MAX)
      cout<<-1;
    else
      cout<<dist[xd][yd];
}


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

using namespace std;

int main()	{
  string s;
  cin >> s;
  int n = s.length();
  int apos = n - 1;
  int zpos = 0;
  for (int i = 0; i < n; i++)	{
    if (s[i] == 'A')
      apos = min(apos, i);
    if (s[i] == 'Z')
      zpos = max(zpos, i);
  }
  cout << zpos - apos + 1 << endl;
  return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL V, E; cin >> V >> E;
		vector<vector<UL>> G(V);
		vector<UL> ins(V);
		rep(i, E) {
			UL a, b; cin >> a >> b;
			G[a].push_back(b);
			ins[b]++;
		}
		queue<UL> Q;
		rep(i, V) if (ins[i] == 0) Q.push(i);
		vector<UL> tro;
		while (Q.size()) {
			UL p = Q.front(); Q.pop();
			tro.push_back(p);
			for (UL e : G[p]) {
				ins[e]--;
				if (ins[e] == 0) Q.push(e);
			}
		}
		rep(i, tro.size()) cout << tro[i] << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 3816
N=int(input())
*H,=map(int,input().split())

ans=0
M=max(H)
count=0
while count<=M:
    if H[0]>=count:
        ans+=1
    i=1
    while i<N:
        if H[i]>=count and H[i-1]<count:
            ans+=1
        i+=1
    count+=1

print(ans-1)

Measured memory_bytes: 9188
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
ans = float('inf')

for i in range(2**N):
    cnt = 0
    last = 0
    cost = 0
    for j in range(N):
        if(A[j] > last):
            cnt += 1
            last = A[j]
        elif(i>>j & 1):
            cnt += 1
            cost += last-A[j]+1
            last += 1
    if(cnt>=K):
        ans = min(ans, cost)
print(ans)

Measured memory_bytes: 3064
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    S = input()

    l = len(S)
    if l % 2:
        print('No')
        return
    elif l == 2:
        if S != 'hi':
            print('No')
            return

    for i in range(0, l - 2, 2):
        if S[i:i+2] != 'hi':
            print('No')
            break
    else:
        print('Yes')


main()


Measured memory_bytes: 3060
import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


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

    n_multiple = [0] * (K + 1)
    for k in range(1, K + 1):
        n_multiple[k] = K // k

    n_gcd = [0] * (K + 1)
    for k in reversed(range(1, K + 1)):
        n_gcd[k] = pow(n_multiple[k], N, mod=P)
        for m in range(2, K // k + 1):
            n_gcd[k] = (n_gcd[k] - n_gcd[k * m]) % P

    ans = 0
    for k in range(1, K + 1):
        ans = (ans + k * n_gcd[k]) % P
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 11892
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt()
  val hashMap = new scala.collection.mutable.HashMap[String, Int]()
  1.to(N).foreach { _ =>
    val word = sc.next()
    val count = hashMap.getOrElse(word, 0)
    hashMap.update(word, count + 1)
  }
  val keys = Seq("AC", "WA", "TLE", "RE")
  keys.foreach { key =>
    val count = hashMap.getOrElse(key, 0)
    println(s"$key x $count")
  }
}


Measured memory_bytes: 59428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=100003,INF=1<<30;

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}

int main(){
    
    int N;cin>>N;
    vector<int> cnt(N,0);
    
    ll ans=1;
    
    for(int i=0;i<N;i++){
        int a;cin>>a;
        cnt[a]++;
        if(i==0){
            if(a!=0) ans=0;
        }
    }
    
    if(cnt[0]!=1) ans=0;
    
    for(int i=1;i<N;i++){
        if(cnt[i]){
            if(cnt[i-1]==0) ans=0;
            
            ans*=rui(cnt[i-1],cnt[i]);
            ans%=mod;
        }
    }
    
    cout<<ans<<endl;
}




Measured memory_bytes: 640
import math
from math import gcd,pi
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    s = s_input()

    r_cn = s.count("R")
    g_cn = s.count("G")
    b_cn = s.count("B")

    ans = r_cn*g_cn*b_cn

    for i in range(n):
        for d in range(n):
            j = i+d
            k = j+d
            if k >=n:
                break
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                ans -= 1
    print(ans)


if __name__=="__main__":
    main()


Measured memory_bytes: 9492
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
using namespace std;
    vector<vector<int> > vec2d_init(int y_len, int x_len){
        vector<vector<int> > vec(y_len, vector<int>(x_len, 0));
        return vec;
    }

    void vec2d_show(vector<vector<int> > vec){
        for(int i = 0; i < vec.size(); i++){
            for(int j = 0; j < vec[0].size(); j++){
                cout << vec[i][j] << " ";
            }
            cout << endl;
        }
    }
    int xo(vector<int> a, vector<int> b, int len){
        int tmp = 0;
        for(int i = 0; i < len; i++){
            tmp += a[i]*b[i];
        }
        return tmp%2;
    }
int main(){
    int N, M;
    cin >> N >> M;
    int k[M];
    int p[M];
    int maxlen = pow(2, N);
    int ans[maxlen];
    vector<vector<int> > conv = vec2d_init(maxlen, N);
    for(int i = 0; i < maxlen; i++){
        for(int j = 0; j < N; j++){
            conv[i][j] = ((int)(i / (maxlen/pow(2, j+1))))%2;
        }
        ans[i] = 1;
    }
    vector<vector<int> > light = vec2d_init(M, N);

    for(int i = 0; i < M; i++){
        cin >> k[i];
        for(int j = 0; j < k[i]; j++){
            int tmp;
            cin >> tmp;
            light[i][tmp-1] = 1;
        }
    }
    for(int i = 0; i < M; i++){
        cin >> p[i];
    }
    for(int i = 0; i < M; i++){
        for(int j = 0; j < maxlen; j++){
            if(p[i] != xo(conv[j], light[i], N)){
                ans[j] = 0;
            }
        }
    }
    int a = 0;
    for(int i = 0; i < maxlen; i++){
        if(ans[i] == 1){
            a++;
        }
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
const long mod=1e9+7;
int N;
long S,T;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		long A;cin>>A;
		S=(S+A*T)%mod;
		T=(T+A)%mod;
	}
	cout<<S<<endl;
}


Measured memory_bytes: 3620
<?php
// in_arrayで真偽を確かめるために配列化する
fscanf(STDIN, "%s", $S);
$S_arr = str_split($S);
// var_dump($S_arr);
$T = ['A','T','C','G'];
$ans = 0;
$now = 0;

foreach ($S_arr as $check) {
 if (in_array($check,$T)) {
    $now++;
    $ans = max($now,$ans);
 }else{
     $now = 0;
 }
}
echo $ans;

Measured memory_bytes: 4604
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n, k;
    cin >> n >> k;

    vs64 a(n);
    rep (i, n)
    {
        cin >> a[i];
    }

    for (int i = k; i < n; ++i)
    {
        if (a[i - k] < a[i]) cout << "Yes\n";
        else cout << "No\n";
    }

    return 0;
}



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

int main() {
	int k,len,delta;
	string s;
	cin>>k>>s;
	len=s.length();
	if(k>=len){
		cout<<s<<endl;
		return 0;
	}else{
		delta=len-k;
		cout<<s.erase(k)<<"..."<<endl;
		return 0;
	}
}

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

int main() {
  int N;
  long K;
  cin >> N >> K;
  int A[N];
  for (int i=0; i<N; i++) {
    cin >> A[i];
    A[i]--;
  }
  int cnt[N], n = A[0], time = 0, ans;
  for (int i=0; i<N; i++)
    cnt[i] = -1;
  cnt[0] = 0;
  while (cnt[n] == -1) {
    time++;
    cnt[n] = time;
    n = A[n];
  }
  if (K<=time) {
    for (int i=0; i<N; i++)
      if (cnt[i]==K)
        ans = i+1;
  } else {
    K -= cnt[n];
    time -= cnt[n]-1;
    int m = K%time;
    for (int i=0; i<N; i++)
      if (cnt[i]==m+cnt[n])
        ans = i+1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5180
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
using namespace std;
typedef long long ll;

int main(void){
    int h, w;
    cin >> h >> w;
    vector<vector<int>> c(10,vector<int>(10));
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            cin >> c[i][j];
        }
    }
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            for(int k=0; k<10; k++){
                c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
            }
        }
    }
    int ai;
    int ans = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> ai;
            if(ai!=-1){
                ans += c[ai][1];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<cstdlib>
#define INF 1 << 30
using namespace std;
int n, m;
int k[160];
vector<int> v[160];
int d[1024][160];
int memo[1024][160][76];
int solve(int x, int y, int c){
  int res = INF;
  if(memo[x][y][c]) return memo[x][y][c];
  if(y + 1 > n || (y + 2 > n && m - c > 0)) return 0;
  if(c < m/* && y <= n - 2*/){
    for(int i = 0;i < k[y + 2]; i++){
      int nx = v[y + 2][i]; int ny = y + 2;
      res = min(res, solve(nx, ny, c + 1) + (d[x][y] + d[nx][ny]) * abs(x - nx));
    }
  }
  for(int i = 0;i < k[y + 1]; i++){
    int nx = v[y + 1][i]; int ny = y + 1;
    res = min(res, solve(nx, ny, c) + (d[x][y] + d[nx][ny]) * abs(x - nx));
  }
  return memo[x][y][c] = res;
}
int main(void){
  int a, b;
  for( ; ; ){
    scanf("%d %d", &n, &m);
    if(!(n + m)) break;
    for(int i = 0;i < 160; i++) v[i].clear();
    memset(memo, 0, sizeof(memo));
    for(int i = 1;i <= n; i++){
      scanf("%d", k + i);
      for(int j = 0;j < k[i]; j++){
	scanf("%d %d", &a, &b);
	v[i].push_back(a);
	d[a][i] = b;
      }
    }
    int ans = INF;
    for(int i = 0;i < k[1]; i++)
      ans = min(ans, solve(v[1][i], 1, 0));
    if(m > 0){
      for(int i = 0;i < k[2]; i++)
	ans = min(ans, solve(v[2][i], 2, 1));
    }
    printf("%d\n", ans);
  }
}


Measured memory_bytes: 50356
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) throws Exception {
        List<Card> cards = new ArrayList<>();
        IntStream.range(0, 13).forEach(i -> cards.add(new Card('S', i + 1)));
        IntStream.range(0, 13).forEach(i -> cards.add(new Card('H', i + 1)));
        IntStream.range(0, 13).forEach(i -> cards.add(new Card('C', i + 1)));
        IntStream.range(0, 13).forEach(i -> cards.add(new Card('D', i + 1)));

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        br.lines().forEach(s -> {
            List<String> list = Arrays.stream(s.split(" "))
                    .collect(Collectors.toList());
            Card card = new Card(list.get(0).charAt(0), Integer.valueOf(list.get(1)));
            cards.remove(card);
        });

        cards.forEach(c -> System.out.println(c.toString()));
    }
}

class Card extends Object {

    private char suit;

    private int number;

    public Card(char suit, int number) {
        this.suit = suit;
        this.number = number;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Card)) {
            return false;
        } else {
            Card card = (Card) object;
            return this.suit == card.suit && this.number == card.number;
        }
    }

    @Override
    public int hashCode() {
        return suit * 100 + number;
    }

    @Override
    public String toString() {
        return String.valueOf(suit) + " " + String.valueOf(number);
    }
}

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

int a[100];

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

  for(int i=0; i<n; i++){
    int k;
    cin >> k;
    for(int j=0; j<k; j++){
      int aa;
      cin >> aa;
      a[aa]++;
    }
  }

  int cnt = 0;
  for(int i=0; i<100; i++){
    if(a[i] == n) cnt++;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>
#include<numeric>

using namespace std;

int n,k;
long long a[100005],b[100005],c[100005];
vector<int> edge[100005];
vector<long long> edgec[100005];
int edgenum[100005];
long long kk[100005];

struct S{
  int i;
  long long p;
};

queue<S> q;

long long calc(){
  for(int i=0;i<n;i++)edgenum[i] = 0;
  for(int i=0;i<n;i++)kk[i] = -1;
  for(int i=0;i<n-1;i++){
    edge[a[i]].push_back(b[i]);
    edge[b[i]].push_back(a[i]);

    edgec[a[i]].push_back(c[i]);
    edgec[b[i]].push_back(c[i]);

    edgenum[a[i]]++;
    edgenum[b[i]]++;
  }

  //for(int i=0;i<n;i++){
  //  for(int j=0;j<edgenum[i];j++)cout<<edge[i][j];cout<<endl;
  //}

  S s;
  s.i = k;
  s.p = 0LL;

  q.push(s);

  while(!q.empty()){
    S tmp = q.front();
    q.pop();
    if(kk[tmp.i] != -1) continue;
    kk[tmp.i] = tmp.p;
    //cout<<"pp "<<tmp.i<<" "<<tmp.p<<endl;
    for(int i=0;i<edgenum[tmp.i];i++){
      S tt;
      tt.i = edge[tmp.i][i];
      tt.p = kk[tmp.i] + edgec[tmp.i][i];
      q.push(tt);
    }
  }

  return 0LL;
}

long long solve(int x, int y){
  return kk[x]+kk[y];
}

int main(){

  cin>>n;
  for(int i=0;i<n-1;i++){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;
    b[i]--;
    //cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<endl;
  }
  int q;cin>>q>>k;
  k--;
  calc();
  for(int i=0;i<q;i++){
    int x,y;cin>>x>>y;
    x--;
    y--;
    cout<<solve(x,y)<<endl;;
  }
  return 0;
}


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

int main(void){
    int n;
    cin >> n;
    if(n < 1200) cout << "ABC" << endl;
    else if (n < 2800)cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}

Measured memory_bytes: 256
let n = stdin.ReadLine() |> int
let [|s;t|] = stdin.ReadLine().Split()

let f (a:char) = string a

let ans = ([for i in 1..n -> ((f s.[i - 1]) + (f t.[i - 1]))] |> List.fold (fun x y -> (x + y)) "")

ans
|>stdout.WriteLine

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

// ====================================================================

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> v[n];
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a, b;
      cin >> a >> b;
      a--;
      v[i].push_back(make_pair(a, b));
    }
  }

  // for (int i = 0; i < n; i++) {
  //   for (auto x : v[i]) {
  //     cout << x.first << "," << x.second << " ";
  //   }
  //   cout << endl;
  // }

  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {  // bit全探索
    bool can = true;
    for (int j = 0; j < n; j++) {         // j人全ての発言を見ていく
      if (((i >> j) & 1) == 0) continue;  // 聞く必要なし
      for (auto x : v[j]) {
        if (((i >> x.first) & 1) != x.second) can = false;
      }
    }
    if (can) {  // もし矛盾がないなら
      int res = 0;
      for (int r = i; r > 0; r >>= 1) res += (r & 1);
      // cout << bitset<8>(i) << " " << res << endl;
      ans = max(ans, res);
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define MAX 100000

struct TRAMP{
    char mark;
    int number,inputed_order;
};

TRAMP cards[MAX];

int n;

int Partition(int left,int right){
    int i = left-1,pivot = cards[right].number;
    for(int start = left; start < right; start++){
        if(cards[start].number <= pivot){
                i++;
                std::swap(cards[i],cards[start]);
        }
    }

    std::swap(cards[i+1],cards[right]);

    return i+1;
}

void quickSort(int left,int right){
    if(left < right){
        int q = Partition(left,right);
        quickSort(left,q-1);
        quickSort(q+1,right);
    }
}


int main(){

    bool stableFLG = true;
    scanf("%d",&n);

    for(int i = 0; i < n; i++){
        scanf("%s %d",&cards[i].mark,&cards[i].number);
        cards[i].inputed_order = i;
    }

    quickSort(0,n-1);

    for(int i = 1; i < n; i++){
        if(cards[i].number == cards[i-1].number && cards[i].inputed_order < cards[i-1].inputed_order){
        	stableFLG = false;
        	break;
        }
    }

    if(stableFLG){
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }

    for(int i = 0; i < n; i++)   printf("%c %d\n",cards[i].mark,cards[i].number);
}


Measured memory_bytes: 4348
#include "bits/stdc++.h"

using namespace std;

class Articulation
{
    using Graph = std::vector<std::vector<int>>;
    using P = std::pair<int, int>;
    std::vector<int> order;
    int next = 0;
    Graph G;
    std::vector<int> ps;

    void add(int v)
    {
        ps.push_back(v);
    }
    int dfs(int cur, int pre)
    {
        int res = order[cur] = next++;
        bool isArticulation = false;
        int d = 0;
        for (const auto &to : G[cur])
        {
            if (to == pre)
                continue;
            if (order[to] >= 0)
                res = std::min(res, order[to]);
            else
            {
                int low = dfs(to, cur);
                if (pre >= 0 && low >= order[cur])
                    isArticulation = true;
                res = std::min(res, low);
                d++;
            }
        }
        if (pre < 0 && d >= 2)
            isArticulation = true;
        if (isArticulation)
            add(cur);
        return res;
    }

  public:
    Articulation(int _v) : G(_v, std::vector<int>()), order(_v, -1) {}
    void addEdge(int s, int t)
    {
        G[s].push_back(t);
    }
    std::vector<int> points()
    {
        dfs(0, -1);
        sort(ps.begin(),ps.end());
        return ps;
    }
};

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

    int V, E;
    cin >> V >> E;
    Articulation arti(V);
    while (E--)
    {
        int s, t;
        cin >> s >> t;
        arti.addEdge(s, t);
        arti.addEdge(t, s);
    }
    auto st = arti.points();
    for (auto p : st)
    {
        cout << p << endl;
    }
}



Measured memory_bytes: 4388
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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

int main(){
    std::ios::sync_with_stdio(false);
    ll h,w,n,a,b;
    map<pair<int,int>, int> counts;
    cin >> h >> w >> n;
    for(int i=0;i<n;++i)
    {
        cin >> a >> b;
        a--;
        b--;
        for(int x=-1;x<=1;++x)
        {
            for(int y=-1;y<=1;++y)
            {
                if((0 < (a+x) && (a+x) < h-1) && (0 < (b+y) && (b+y) < w-1))
                {
                    counts[MP(a+x, b+y)] += 1;
                }
            }
        }
    }
    ll ret[10] = {};
    ll sum_black = 0;
    for(auto& pair : counts)
    {
        //cout << pair.first.first << " " << pair.first.second << " " << pair.second << endl;
        ret[pair.second]++;
        sum_black++;
    }
    ret[0] = (h-2) * (w-2) - sum_black;
    for(int i=0;i<10;i++)
    {
        cout << ret[i] << endl;
    }
}


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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    vector<int> RGB(3);
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') {
            RGB[0]++;
        } else if (S[i] == 'G') {
            RGB[1]++;
        } else {
            RGB[2]++;
        }
    }
    int temp = 0;
    for (int i = 1; i * 2 < N; i++) {
        for (int j = 0; j + i * 2 < N; j++) {
            if (S[j] != S[j+i] && S[j+i] != S[j+i*2] && S[j+i*2] != S[j]) temp++;
        }
    }
    cout << (long long) RGB[0] * RGB[1] * RGB[2] - temp << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>

char buf[1<<21], *p1, *p2;
#define getc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<21, stdin)), p1 == p2 ? EOF : *p1++)
#define lint long long
#define isnum(x) ('0' <= (x) && (x) <= '9')
template<typename tint>
inline void readint(tint& x) {
	int f = 1; char ch = getc(); x = 0;
	for(; !isnum(ch); ch = getc()) if(ch == '-') f = -1;
	for(; isnum(ch); ch = getc()) x = x * 10 + ch - '0';
	x *= f;
}
using namespace std;
const int maxa = 12;
const int maxn = 204;

// dist[x][y] = min{i * x + j * y + f[i][j]}
// dist[x][y] - i * x - j * y <= f[i][j]
// f[i][j] = max{dist[x][y] - i * x - j * y}

// f[i][j] = max{dist[x][y] - i * x - j * y}

int n = 202, m = 100;
int A, B;
int dist[maxa][maxa], f[maxn][maxn];
int edge[maxn][maxn];
int now[maxn];
bool vis[maxn];

int main() {
	memset(f, -1, sizeof(f)), memset(edge, -1, sizeof(edge));
	readint(A), readint(B);
	for(int i=1; i<=A; i++) {
		for(int j=1; j<=B; j++) readint(dist[i][j]);
	}

	int cnt = 0;
	for(int i=0; i<=m; i++) {
		for(int j=0; j<=m; j++) {
			for(int x=1; x<=A; x++) {
				for(int y=1; y<=B; y++) {
					f[i][j] = max(f[i][j], dist[x][y] - i * x - j * y);
				}
			}
			// i个x, j个y的最短路
			edge[i + 1][202 - j] = f[i][j];
			if(edge[i + 1][202 - j] != -1) cnt++;
		}
	}


	for(int a=1; a<=A; a++) {
		for(int b=1; b<=B; b++) {
			for(int i=1; i<=100; i++) edge[i][i+1] = a;
			for(int i=102; i<=201; i++) edge[i][i+1] = b;
			memset(vis, 0, sizeof(vis)), memset(now, 0x3f, sizeof(now));
			now[1] = 0;
			while(true) {
				int x = 0;
				for(int i=1; i<=n; i++) if(!vis[i] && now[i] < now[x]) x = i;
				if(x == 0) break;
				vis[x] = 1;
				for(int y=1; y<=n; y++)
					if(edge[x][y] != -1 && now[y] > now[x] + edge[x][y]) now[y] = now[x] + edge[x][y];
			}
			if(now[n] != dist[a][b]) { puts("Impossible"); return 0; }
		}
	}

	puts("Possible");
	printf("%d %d\n", n, cnt + 200);
	for(int i=1; i<=100; i++) printf("%d %d X\n", i, i+1);
	for(int i=102; i<=201; i++) printf("%d %d Y\n", i, i+1);
	for(int i=0; i<=m; i++) {
		for(int j=0; j<=m; j++) {
			if(f[i][j] == -1) continue;
			printf("%d %d %d\n", i + 1, 202 - j, f[i][j]);
		}
	}
	printf("%d %d\n", 1, 202);
	// [1, 101] [102, 202]
	//
	
	
	
	
	return 0;
}

// Y
// X + 1
// X + X
// 3

// x = 2, y = 3


Measured memory_bytes: 640
//piupiuplu

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

double a[12][12];

int main()
{
  int n,d;
  cin>>n>>d;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=d;j++)
      cin>>a[i][j];
  int baga=0;
  for(int i=1;i<n;i++)
    for(int j=i+1;j<=n;j++)
      {
	double p=0;
	for(int k=1;k<=d;k++)
	  p+=pow(a[i][k]-a[j][k],2);
	p=sqrt(p);
	if(p==floor(p))
	  baga++;
      }
  cout<<baga;
  return 0;
}

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

using namespace std;

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

    int num[110] = { 0 };  // バケット
    for (int i = 0; i < N; ++i) {
        num[d[i]]++;  // d[i] が 1 個増える
    }

    int res = 0;  // 答えを格納
    for (int i = 1; i <= 100; ++i) {  // 1 <= d[i] <= 100 なので 1 から 100 まで探索
        if (num[i]>0){  // 0 より大きかったら
            ++res;
        }
    }
    cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main(A, H, W, K, S):
    INF = 10**9
    dist = np.full(H * W, INF, np.int32)
    q = np.empty(H * W + 100, np.int32)
    q[:2] = 2, 2

    def push(q, x):
        q[q[1]] = x
        q[1] += 1

    def pop(q):
        q[0] += 1
        return q[q[0] - 1]

    def is_empty(q):
        return q[0] == q[1]

    move = (1, -1, W, -W)
    dist[S] = 0
    push(q, S)
    while not is_empty(q):
        v = pop(q)
        for d in (1, -1, W, -W):
            w = v + d
            if A[w] == '#' or dist[w] <= dist[v] + 1:
                continue
            dist[w] = dist[v] + 1
            push(q, w)
    dist = dist.reshape(H, W)
    min_d = INF
    for h in range(1, H - 1):
        for w in range(1, W - 1):
            if dist[h, w] > K:
                continue
            d = min(h - 1, H - 2 - h, w - 1, W - 2 - w)
            min_d = min(d, min_d)
    return 1 + (min_d + K - 1) // K

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.from_dtype(np.int64)
    u1 = numba.from_dtype(np.dtype('U1'))
    signature = (u1[:], i8, i8, i8, i8)

    cc = CC('my_module')
    cc.export('main', signature)(main)
    cc.compile()

from my_module import main

H, W, K = map(int, readline().split())
A = np.full((H + 2, W + 2), '#', 'U1')
A[1:-1, 1:-1] = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W]

H, W = A.shape
A = A.ravel()
S = np.where(A == 'S')[0][0]

print(main(A, H, W, K, S))

Measured memory_bytes: 34168
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  vector<vector<int>> vec(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>vec.at(i).at(j);
    }
  }
   ll a;
  cin>>a;
  vector<int> ans(a);
  for(int i=0;i<a;i++){
    cin>>ans.at(i);
  }
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<a;k++){
        if(vec.at(i).at(j)==ans.at(k)){
          vec.at(i).at(j)=0;
        }
      }
    }
  }
  if(vec.at(0).at(0)==0 && vec.at(0).at(1)==0 && vec.at(0).at(2)==0){cout<<"Yes"<<endl;}
  else if(vec.at(1).at(0)==0 && vec.at(1).at(1)==0 && vec.at(1).at(2)==0){cout<<"Yes"<<endl;}
  else if(vec.at(2).at(0)==0 && vec.at(2).at(1)==0 && vec.at(2).at(2)==0){cout<<"Yes"<<endl;}
  else if(vec.at(0).at(0)==0 && vec.at(1).at(0)==0 && vec.at(2).at(0)==0){cout<<"Yes"<<endl;}
  else if(vec.at(0).at(1)==0 && vec.at(1).at(1)==0 && vec.at(2).at(1)==0){cout<<"Yes"<<endl;}
  else if(vec.at(0).at(2)==0 && vec.at(1).at(2)==0 && vec.at(2).at(2)==0){cout<<"Yes"<<endl;}
  else if(vec.at(0).at(0)==0 && vec.at(1).at(1)==0 && vec.at(2).at(2)==0){cout<<"Yes"<<endl;}
  else if(vec.at(0).at(2)==0 && vec.at(1).at(1)==0 && vec.at(2).at(0)==0){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
using namespace std;


#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef pair<int, int> Edge;

ll A[505][505];
ll B[505][505];
ll H, W,key=0,abc=0,coun=0,coun2=0,N=0;
queue<int> q1;

void serch(int x,int y) {
	if (key == 1) {
		q1.push(x);
		q1.push(y);
		if (A[x][y] % 2 == 1) {
			key = 0;
			coun2++;
			abc = 0;
		}
	}else {
		if (A[x][y] % 2 == 1) {
			coun2++;
			key = 1;
		}
	}
	
	if (coun == coun2||(H%2==0&&x==H&&y==1)||(H%2==1&&x==H&&y==W))return;

	if (x % 2 == 0 && y!=1) {
		if (key == 1) {
			abc++;
			N++;
			q1.push(x);
			q1.push(y);
		}
		serch(x, y - 1);
		return;
	}
	else if (x%2==1&&y!=W) {
		if (key == 1) {
			abc++;
			N++;
			q1.push(x);
			q1.push(y);
		}
		serch(x, y + 1);
		return;
	}
	else if ((x % 2 == 0 && y == 1)||(x % 2 == 1 && y == W)) {
		if (key == 1) {
			N++;
			abc++;
			q1.push(x);
			q1.push(y);
		}
		serch(x + 1, y);
		return;
	}
	else {
		cout << "AAAAAAAA" << endl;
		cout << x << " " << y << endl;
	}
}

int main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> A[i][j];
			if (A[i][j] % 2 == 1)coun++;
		}
	}
	
	serch(1, 1);
	cout << N - abc << endl;
	while (N-abc) {
		for (int i = 0; i < 4; i++) {
			cout << q1.front() << (i == 3 ? "\n" : " ");
			q1.pop();
		}
		N--;
	}

}


Measured memory_bytes: 17920
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<int> a(n), b(n);
    for (int &x : a) {
        cin >> x;
    }
    for (int &x : b) {
        cin >> x;
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        res += max(0, a[i] - b[i]);
    }
    cout << res << "\n";
}


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

int main()
{
    // ここにプログラムを追記
    string a;
    int cnt = 0;

    cin >> a;

    for (int i = 0; i < 3; i++)

        if (a[i] == '1')
        {
            cnt += 1;
        }

    cout << cnt << endl;
}


Measured memory_bytes: 3624
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef bitset<16> BS;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 8000;

int x, y;

string s;

bool dpx[MAX_N][MAX_N * 2], dpy[MAX_N][MAX_N * 2];
vector<int> L[2];

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

    cin >> s >> x >> y;

    bool isx = 0;
    int l = 0;
    L[0].push_back(0);
    L[1].push_back(0);
    /*
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'F') {
            l++;
        } else {
            if (l > 0) {
                L[isx].push_back(l);
            }
            isx = !isx;
            l = 0;
        }

        if (s[i] == 'F' && i == s.size() - 1) {
            L[isx].push_back(l);
        }
    }
    int l = 0;
    */
    for (const auto& c : s) {
        if (c == 'F') {
            l++;
        } else {
            L[isx].push_back(l);
            l = 0;
            isx = !isx;
        }
    }
    L[isx].push_back(l);
    int xmax = 0;
    for (int i = 1; i < L[0].size(); i++) {
        xmax += L[0][i];
    }
    int ymax = 0;
    for (int i = 1; i < L[1].size(); i++) {
        ymax += L[1][i];
    }

    dpx[0][xmax] = 1;
    for (int i = 0; i < L[0].size() - 1; i++) {
        for (int j = 0; j <= 2 * xmax; j++) {
            if (i == 0 && s[0] == 'F') {
                dpx[i + 1][j + L[0][i + 1]] |= dpx[i][j];
            } else {
                dpx[i + 1][j + L[0][i + 1]] |= dpx[i][j];
                if (j >= L[0][i + 1]) {
                    dpx[i + 1][j - L[0][i + 1]] |= dpx[i][j];
                }
            }
        }
    }

    dpy[0][ymax] = 1;
    for (int i = 0; i < L[1].size() - 1; i++) {
        for (int j = 0; j <= 2 * ymax; j++) {
            dpy[i + 1][j + L[1][i + 1]] |= dpy[i][j];
            if (j >= L[1][i + 1]) {
                dpy[i + 1][j - L[1][i + 1]] |= dpy[i][j];
            }
        }
    }

    /*
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < L[i].size(); j++) {
            cout << "i = " << i << ", j = " << j << ", L = " << L[i][j] << "\n";
        }
    }

    for (int i = 0; i < L[0].size(); i++) {
        for (int j = 0; j <= 2 * xmax; j++) {
            cout << "i = " << i << ", j = " << j << ", dpx = " << dpx[i][j] << "\n";
        }
    }
    for (int i = 0; i < L[1].size(); i++) {
        for (int j = 0; j <= 2 * ymax; j++) {
            cout << "i = " << i << ", j = " << j << ", dpy = " << dpy[i][j] << "\n";
        }
    }
    */

    if (dpx[L[0].size() - 1][x + xmax] && dpy[L[1].size() - 1][y + ymax]) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 38704
import std.stdio, std.string, std.conv, std.algorithm, std.math;

void main() {
    int n = readln.chomp.to!int;
    int[] w = readln.split.to!(int[]);
    int l, r = w.sum;
    int diff = r;
    foreach (i; 0 .. n) {
        l += w[i];
        r -= w[i];
        if (abs(l-r) > diff) break;
        diff = abs(l-r);
    }
    diff.writeln;
}

Measured memory_bytes: 256