akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
typedef long long ll;
ll n,m,l,r;
int main()
{
	scanf("%lld %lld",&n,&m);
	if(m/2>n)
	{
		l=(m/2-n)*2/4;
		l=l+n;
		printf("%lld\n",l);
	}
	else if(m/2==n)
	{
		printf("%lld\n",n);
	}
	else if(m/2<n)
	{
		printf("%lld\n",m/2);
	}
	return 0;
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;
ll n, m;

bool check(const Graph &G, const vector<ll> &v)
{
	if (v[0] != 0) return false;

	vector<bool> seen(n, false);
	seen[0] = true; // start
	for (int i = 0; i < n-1; ++i)
	{
		ll current{v[i]};
		ll target{v[i+1]};
		
		bool flag{false};
		for (auto e : G[current])
			if (e == target) flag = true;

		if (!flag) return false;
		else seen[target] = true;

		flag = true;
		for (size_t i = 0; i < v.size(); ++i)
			if (!seen[i]) flag = false;
		if (flag) return true;
	}

	return false;
}

template <class Iterator>
void show(Iterator begin, Iterator end)
{
	for (; begin != end; ++begin)
		std::cout << *begin + 1 << " ";
	std::cout << std::endl;
}

int main(int argc, char **argv)
{
	cin >> n >> m;
	Graph G(n);

	for (ll i = 0; i < m; ++i)
	{
		ll a, b; cin >> a >> b; --a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	vector<ll> v;
	for (ll i = 0; i < n; ++i)
		v.push_back(i);

	ll count{0};
	do
	{
		if (v[0] != 0) break;
		if (check(G, v))
		{
			++count;
//			show(v.begin(), v.end());
		}
	} while (next_permutation(v.begin(), v.end()));
	std::cout << count << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <deque>
#include <stack>

using namespace std;

typedef long long ll;

ll kol, N, B[100005], m1, m2, p;

bool cmp(pair<ll, ll> a, pair<ll, ll> b){
     return (a.first < b.first || a.first == b.first && a.second > b.second) ? 1 : 0;
}

int main(){
     ios_base::sync_with_stdio(0);
     cin.tie(0);
     //freopen("1.out", "w", stdout);
     
	 ll i, a;
	 
	 cin >> N;
	 
	 vector<pair<ll,ll> > A;
	 a=0;
	 A.push_back(make_pair(0,0));
	 
	 for(i=1; i<=N; i++){
         cin >> a;
         A.push_back(make_pair(a, i));
     }
     
     sort(A.rbegin(), A.rend()-1, &cmp);
     
     set<ll> S;
     
     i = 1;
     ll k;
     while(i <= N){
             m1 = A[i].first;
             
             while (i + 1 <= N && A[i].first == A[i+1].first) {
                   S.insert(A[i].second);
                   i++;
             }
             S.insert(A[i].second);
             k = i;
             i++;
             
             if (i <= N) m2 = A[i].first;
             else m2 = 0;
             
             p = *S.begin();
             
             B[p] += k*(m1 - m2);  
             // cout << m1 << ' ' << p << ' ' << m2 << endl;      
     }
	 
	 for(i=1; i<=N; i++){
         cout << B[i] << "\n";
     }
     
	 cout.flush();
	 
     cin >> N;
	 
	 exit(0);
}


Measured memory_bytes: 8176
import itertools
import math

def main():
    n = int(input())
    ls = [list(map(int,input().split())) for i in range(n)]
    ans = 0
    comb = 0

    for i in itertools.permutations(range(n)):
        comb += 1
        for j in range(n-1):
            ans += math.sqrt((ls[i[j]][0]-ls[i[j+1]][0])**2 + (ls[i[j]][1]-ls[i[j+1]][1])**2)
    print(ans/comb)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
def bfs(n,e,fordfs,D):
    #点の数、スタートの点、有向グラフ
    W = [-1]*(n-1)
    #各点の状態量、最短距離とか,見たかどうかとか
    used = defaultdict(bool)
    que = deque()
    que.append(e)
    while que:
        now = que.popleft()
        i = 1
        for ne in fordfs[now]:
            l = min(now,ne); r = max(now,ne)
            if W[D[(l,r)]] == -1:
                while(True):
                    if not used[(now,i)]:
                        used[(now, i)] = True
                        used[(ne, i)] = True
                        break
                    i +=1
                que.append(ne)
                W[D[(l,r)]] = i
    return W
def examD():
    N = I()
    V = [[]for _ in range(N)]
    d = defaultdict(int)
    for i in range(N-1):
        a, b = LI()
        V[a-1].append(b-1)
        V[b-1].append(a-1)
        d[(a-1,b-1)] = i
    ans = bfs(N,0,V,d)
    print(max(ans))
    for v in ans:
        print(v)
    return

def examF():
    N, M = LI()
    S = SI()
    ans = []
    cur = N
    while(cur>0):
        k = min(M,cur)
        while(S[cur-k]=="1"):
            k -=1
            if k==0:
                print("-1")
                return
        ans.append(k)
        cur -=k
    for v in ans[::-1]:
        print(v)
    return


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examF()


Measured memory_bytes: 49184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,x) for(int i = 0; i <x; i++)
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

int main(){
  int X, N;
  cin >> X >> N;

  set<int>se;

  rep(i,N) {
    int p;
    cin >> p;

    se.insert(p);
  }


  int dist = 1;
  if(se.find(X) == se.end()){
    cout << X << endl;
    return 0;
  }


  while(1){
    if(se.find(X-dist) == se.end() ){
      cout << X-dist <<endl;
      return 0;
    }else if(se.find(X+dist) == se.end()){
      cout<<X+dist<<endl;
      return 0;
    }
    dist++;
  }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define pb push_back;
using namespace std;
ll cnt,mini=1e9,maxi=-1;
ll n,m,k,x;
ll mini1=1e9,maxi1=-1,cnt1,cnt2,cnt3,ans,sum;
int main(){
ios_base::sync_with_stdio(0);
	// freopen (" .txt", "r", stdin);
	// freopen (" .txt", "w", stdout);
	string a,s;
	cin>>a>>s;
	cin>>n>>m;
	string d;
	cin>>d;
	if(d==a){
		cout<<n-1<<" "<<m;
	return 0;
	}
	cout<<n<<" "<<m-1;
}
//     *    *  *  ****    *    *   *
//    *	*   * *   *      * *   *   *
//   *****  **    ****  *****  *****
//   *   *  * *      *  *   *      *
//   *   *  *  *  ****  *   *  *****

//   ****  ****  *       *
//   *      **   *      * *
//   ****   **   *     *****
//      *   **   *     *   *
//   ****  ****  ****  *   *


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

int main(){
    int n;
    cin>>n;
    set<int> st;
    for(int i=1;i<=n;i++){
        int m=i*1.08;
        if(m==n) st.insert(i);
    }
    if(st.size()>0)cout<<*begin(st)<<endl;
    else cout<<":("<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

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

using namespace std;

int n;
int t[10004];
long long wait_time[10004];
void solve() {
    rep(i, n) wait_time[i] = 0;
    sort(t, t + n);
    rep(i, n) if (i) wait_time[i] += t[i - 1] + wait_time[i - 1];
    long long ans = 0;
    rep(i, n) ans += wait_time[i];
    cout << ans << endl;
}
int main() {
    while (cin >> n) {
        if (n == 0) break;
        rep(i, n) cin >> t[i];
        solve();
    }
}

Measured memory_bytes: 3260
#include<iostream>
#include<cstdint>
using namespace std; // 575

int main() {
	int64_t N, A[5];
	cin >> N >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
	int64_t ma = 0;
	for (int i = 0;i < 5;++ i) ma = max(ma, (N + A[i] - 1) / A[i]);
	cout << ma + 4;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

都市1から2へ最後に移動する人は、時間ceil(N/A)で移動する
この人が都市2から3へ移動するのは？
まず、A<Bなら単に1分後には移動できる
A>Bなら、ceil(N/B)+1分後には移動できるはず
結論、max(ceil(N/A), ceil(N/B)...)+4
*/

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF 2000000000

typedef long long ll;

void rec(int a, int b){
    if(a < 0 && b < 0){
        if ((b - a)%2 == 1){
            cout << "Positive" << endl;
        }else{
            cout << "Negative" << endl;
        }
    }else if(a > 0 && b > 0){
        cout << "Positive" << endl;
    }else{
        cout << "Zero" << endl;
    }
}

int main(){
    INT(a);INT(b);
    rec(a,b);
    return 0;
}

Measured memory_bytes: 256
n = int(input())

s = 0
if (n & 1) == 1:
    s = n
    print((n-1) * (n-1) // 2)
else:
    s = n+1
    print((n-2) * n // 2)
for i in range(1, n+1):
    for j in range(i+1, n+1):
        if i + j != s:
            print(i, j)


Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>

int **G;
int *u, *k, **v;
int n;

void Input();
void CreateAdjacencyMatrix(int); 
void Output();


int main () {
  
  Input();
  Output();
  
  return 0;
}


void Input() {
  int i, j;
  
  scanf("%d", &n);
  
  k = (int *)malloc(sizeof(int) * (n + 1));
  u = (int *)malloc(sizeof(int) * (n + 1));
  G = (int **)malloc(sizeof(int *) * (n + 1));
  v = (int **)malloc(sizeof(int *) * (n + 1));
  
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &u[i], &k[i]);
    G[i] = (int *)malloc(sizeof(int) * (n + 1));
    v[i] = (int *)malloc(sizeof(int) * (k[i] + 1));
    for (j = 1; j <= k[i]; j++) {
      scanf("%d", &v[i][j]);
    }
  }
  
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      G[i][j] = 0;
    }
  }
}

void CreateAdjacencyMatrix(int a) {
  int i, j;
  for (i = 1; i <= k[a]; i++) {
    for (j = 1; j <= n; j++) {
      if (u[j] == v[a][i])
	G[a][u[j]] = 1;
    }
  }
}

void Output() {
  int i, j;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      CreateAdjacencyMatrix(i);
      /*if (j != 1) printf(" ");*/
      printf("%d", G[i][j]);
      if(j==n) break;
      else printf(" ");
    }
    puts("");
    free(G[i]);
    free(v[i]);
  }
  free(u);
  free(k);
  free(G);
  free(v);
}

Measured memory_bytes: 656
import scala.io.StdIn.readLine

object Types {
  type Roll = ((Int,Int,Int,Int,Int,Int))=>(Int,Int,Int,Int,Int,Int)
}
import Types._

class Dice(var d:(Int,Int,Int,Int,Int,Int)) {
  val fs = (x:(Int,Int,Int,Int,Int,Int)) => x match {case (x1,x2,x3,x4,x5,x6) => (x5,x1,x3,x4,x6,x2) }
  val fw = (x:(Int,Int,Int,Int,Int,Int)) => x match {case (x1,x2,x3,x4,x5,x6) => (x3,x2,x6,x1,x5,x4) }

  def roll(dir:Char)  =
    dir match {
      case 'S' => fs
      case 'N' => fs compose fs  compose fs
      case 'W' => fw
      case 'E' => fw compose fw compose fw
    }

  def apply(f:Roll) = this.d = f(this.d)
  def getTopFace() = d._1.toString
}

object Main extends App {

  val faces = readLine.split(" ").map(_.toInt) match { case Array(x1,x2,x3,x4,x5,x6) => (x1,x2,x3,x4,x5,x6) }
  val dice = new Dice(faces)
  var rolls:Roll = x=>x

  dice.apply(readLine.foldLeft(rolls) { (x:Roll,y) => dice.roll(y) compose x })
  println(dice.getTopFace)
}

Measured memory_bytes: 44084
#include <iostream>
using namespace std;
int main(){
	int a,b;
	int s = 0;
	int v = 0;
	int n = 0;
	char c;
	while(cin >> a >> c >> b){
		s += a*b;
		v += b;
		n++;
	}
	int d = v/n;
	if((v-(d*n))*2>=n) d++;
	cout << s << endl;
	cout << d << endl;
}

Measured memory_bytes: 1160
# 入力
s = input()
K = int(input())

# 先頭文字から順に可能な限りaにする
# 余った操作回数はすべて末尾文字に適用する
t = list(s)
L = K
for i in range(len(s)):
    d = 123 - ord(s[i])
    if 1 <= d <= min(25, L):
        t[i] = 'a'
        L -= d
t[-1] = chr((ord(t[-1]) - 97 + L) % 26 + 97)
ans = ''.join(t)

# 出力
print(ans)


Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a!=b&&b!=c&&a!=c){
		cout<<3<<endl;
	}
	else if(a==b&&b==c){
		cout<<1<<endl;
	}
	else{
		cout<<2<<endl;
	}
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

int N;
char digit[4];

int main()
{
    ZERO(digit);
    cin >> digit[0] >> digit[1] >> digit[2] >> digit[3];
    REP(i, 4) {
        digit[i] -= '0';
    }

    REP(i, 8) {
        int cand = digit[0];
        char sign[3];
        if((i & 1) == 0) {
            cand += digit[1];
            sign[0] = '+';
        } else {
            cand -= digit[1];
            sign[0] = '-';
        }
        if(((i >> 1) & 1) == 0) {
            cand += digit[2];
            sign[1] = '+';
        } else {
            cand -= digit[2];
            sign[1] = '-';
        }
        if(((i >> 2) & 1) == 0) {
            cand += digit[3];
            sign[2] = '+';
        } else {
            cand -= digit[3];
            sign[2] = '-';
        }
        if(cand == 7) {
            printf("%d%c%d%c%d%c%d=7\n", digit[0], sign[0], digit[1], sign[1],
                    digit[2], sign[2], digit[3]);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	
	void cal()
	{
	Scanner sc=new Scanner(System.in);
	int a=sc.nextInt();
	int b=sc.nextInt();
	String as="",bs="";
	
	for(int i=0;i<b;i++)
	{
		as+=a;
	}
	for(int i=0;i<a;i++)
	{
		bs+=b;
	}
	if(a<b)
	{
		System.out.println(as);
		
		
	}
	else if(a>b)
	{
		System.out.println(bs);
		
		
	}
	else if(a==b)
	{
		System.out.println(bs);
		
		
	}
	sc.close();
	
}



public static void main (String args[])
{
	Main obj= new Main();
	obj.cal();

}
}





Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
using namespace std;

long long N, X[109], Y[109], H[109];
vector<tuple<long long, long long, long long>>vec;

int main(){
    cin >> N;
    tuple<long long, long long, long long>G = make_tuple(-1, -1, -1);
    for(int i=1; i<=N; i++){
        cin >> X[i] >> Y[i] >> H[i];
        if(H[i]>0)G = make_tuple(X[i], Y[i], H[i]);
    }

    for(int i=0; i<=100; i++){
        for(int j=0; j<=100; j++){//ちゅうしん(i, j)
            long long V = get<2>(G) + abs(get<0>(G) - i) + abs(get<1>(G) - j);
            V = max(V, 0LL);
            bool flag = true;
            for(int k=1; k<=N; k++){
                long long VV = V - abs(X[k]-i) - abs(Y[k]-j);
                VV = max(VV, 0LL);
                if(H[k] != VV){
                    flag = false;
                    break;
                }
            }
            if(flag == true){
                vec.push_back(make_tuple(i, j, V));
            }
        }
    }
    cout << get<0>(vec[0]) << ' ' << get<1>(vec[0]) << ' ' << get<2>(vec[0]) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        String s = sc.next();
        if(n>=3200){
            System.out.println(s);
        }else{
            System.out.println("red");
        }
    }
}


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

int abs(int a,int b){
  if(a<b)
    return b-a;
  else
    return a-b;
}

int main(){
  int n,ch;
  cin >> n;
  vector<int> x(n),y(n),h(n);
  int X,Y,H;
  bool hh=false;
  for(int i=0;i<n;i++)
    cin >> x[i] >> y[i] >> h[i];
  for(int i=0;i<n;i++){
    if(h[i]!=0)
      ch=i;
  }
  for(int i=0;i<101;i++){
    for(int j=0;j<101;j++){
      int xx;
      bool ju=true;
      xx=h[ch]+abs(x[ch],i)+abs(y[ch],j);
      for(int k=0;k<n;k++){
        int yy=max(xx-abs(x[k],i)-abs(y[k],j),0);
        if(yy!=h[k]){
          ju=false;
          break;
        }
      }
      if(ju){
        X=i;Y=j;H=xx;
        hh=true;
        break;
      }
    }
    if(hh)
      break;
  }
  cout << X << ' ' << Y << ' ' << H << endl;
  //cout << ch << endl;
}
                     

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

using namespace std;
#define ll long long

int main() {
    int a,b,c;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);


    if(a == b && b == c) printf("No\n");
    else if(b == c) printf("Yes\n");
    else if(a == b) printf("Yes\n");
    else if(a == c) printf("Yes\n");
    else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
char s[50],a[9]={5,7,5,7,7,-1};
main(){for(int i,j,p,n,q;scanf("%d\n",&n),n;){for(i=0;i<n;s[i++]=strlen(gets(s+i)));
for(i=j=0;j<6;i++)for(p=i,j=q=0;q>=0;)for(q=a[j++];q>0;q-=s[p++]);
printf("%d\n",i);
}}

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

int main(){
  int n,mi=10000,s1,s2;cin>>n;
  vector<int> w(n,0);
  REP(i,n) cin>>w.at(i);
  REP(i,n-1){
    s1=s2=0;
    REP(j,n){
      if(j<=i) s1+=w.at(j);
      else s2+=w.at(j);
    }
    mi=min(mi,abs(s1-s2));
  }
  cout<<mi;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define ifr(a, value) insert(a.begin(), value)
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define szz(v) ((int)(v).size())  
#define vi vector<int>
#define vll vector<ll>
#define str string
#define fr(i, j, k) for(i = j; i < k; i++)
#define bk(i, j, k) for(i = j; i >= k; i--)
#define frit(a, it) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)        // use fill() for value other than 0 //
#define rtn return 
#define clk fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock()/CLOCKS_PER_SEC)
#define nl "\n"
#define inf 1LL<<61
#define dbg(x) (cerr << #x << ": " << x << "\n")
const long long mod = 1e9+7;

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }   // no need to swap a, b, it auto. happens after first call //
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

int a[27];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, i, j;
    cin >> n;
    str s;
    cin >> s;
    int mx = 0;
    fr(i, 0, n)
    {
        fr(j, i+1, n)
        {
            int cnt = 0;
           for(char c = 'a'; c <= 'z'; c++)
           {
               bool q = 0, w = 0;
               for(int k=0; k<j; k++)
                   if(s[k]==c)
                   {
                       q = 1;
                       break;
                   }
               for(int k=j; k<n; k++)
                   if(s[k] == c)
                   {
                       w = 1;
                       break;
                   }
               if(q && w) cnt++;
                       
           }
            mx = max(mx, cnt);
         //   dbg(cnt); dbg(mx); dbg(j);
        }
    }
    cout << mx;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int H, W;
  char a[110][110] = {};
  int b[110][110] = {};
  int i, j, k;
  int flag, flag2;//行または列が白マスのみからなるならば1，そうでなければ0

  scanf("%d %d", &H, &W);
  for(i = 0; i < H; i++){
    scanf("%s", &a[i][0]);
  }

  for(i = 0; i < H; i++){
    for(j = 0; j < W; j++){
      //i行が白マスのみからなるか確認
      flag = 1;
      for(k = 0; k < W; k++){
        if(a[i][k] == '#'){
          flag = 0;
          break;
        }
      }
      //ここで flag == 1 ならば，i行は白マスのみからなる

      //j列が白マスのみからなるか確認
      flag2 = 1;
      for(k = 0; k < H; k++){
        if(a[k][j] == '#'){
          flag2 = 0;
          break;
        }
      }
      //ここで flag2 == 1 ならば，j列は白マスのみからなる

      //i行，j列が共に白マスのみからなるならば，a[i][j]を出力
      if(flag == 0 && flag2 == 0){
        printf("%c", a[i][j]);
      }
    }
    //ここで flag == 1 ならば，i行は白マスのみからなる
    if(flag == 0){
      printf("\n");
    }
  }


  return 0;
}


/*これではできなかった．なぜ？
void swap(char *a, char *b){
  char buf;
  buf = (*b);
  (*b) = (*a);
  (*a) = buf;
}

int main(void){
  int H, W;
  char a[110][110] = {};
  int i, j, k;
  int flag;//行または列が白マスのみからなるならば1，そうでなければ0

  scanf("%d %d", &H, &W);
  for(i = 0; i < H; i++){
    scanf("%s", &a[i][0]);
  }

  for(i = 0; i < H; i++){
    do{
      //i行が白マスのみからなるか確認
      flag = 1;
      for(j = 0; j < W; j++){
        if(a[i][j] == '#'){
          flag = 0;
          break;
        }
      }
      //ここでflag == 1ならば，i行は白マスのみからなる
      if(flag == 1){
        //i行を空文字にする
        for(j = 0; j < W; j++){
          a[i][j] = 0;
        }
        //i行を詰める
        for(j = i+1; j < H; j++){
          //j行とj-1行を交換
          for(k = 0; k < W; k++){
            swap(&a[j][k], &a[j-1][k]);
          }
        }
        H--;
        if(i < H){
          //i < Hのとき，再びi行が白マスのみからなるか確認
          flag = 1;
          for(j = 0; j < W; j++){
            if(a[i][j] == '#'){
              flag = 0;
              break;
            }
          }
        }
        //ここでflag == 1ならば，i行は白マスのみからなる
      }
    }while(flag == 1);
  }

  for(i = 0; i < W; i++){
    do{
      //i列が白マスのみからなるか確認
      flag = 1;
      for(j = 0; j < H; j++){
        if(a[j][i] == '#'){
          flag = 0;
          break;
        }
      }
      //ここでflag == 1ならば，i列は白マスのみからなる
      if(flag == 1){
        //i列を空文字にする
        for(j = 0; j < H; j++){
          a[j][i] = 0;
        }
        //j列を詰める
        for(j = i+1; j < W; j++){
          //j列とj-1列を交換
          for(k = 0; k < H; k++){
            swap(&a[k][j], &a[k][j-1]);
          }
        }
        W--;
        if(i < W){
          //i < W のとき，再びi列が白マスのみからなるか確認
          flag = 1;
          for(j = 0; j < H; j++){
            if(a[j][i] == '#'){
              flag = 0;
              break;
            }
          }
        }
        //ここでflag == 1ならば，i列は白マスのみからなる
      }
    }while(flag == 1);
  }

  for(i = 0; i < H; i++){
    printf("%s\n", &a[i][0]);
  }
  return 0;
}
*/


Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll n,k;
  cin >> n >> k;
  vi a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) a[i]--;
  int cnt = 0;
  int roopcnt = 0;
  int roopPos = 0;
  int current = 0;
  vi check(n, 0);
  check[0] = 1;
  for(int i = 0; ; i++){
    current = a[current];
    cnt++;
    if(check[current]){
      roopPos = current;
      break;
    }
    check[current] = 1;
  }
  if(cnt >= k){
    current = 0;
    for(int i = 0; i < k; i++){
      current = a[current];
    }
    cout << current + 1 << endl;
    return 0;
  }
  for(int i = 0; ; i++){
    current = a[current];
    roopcnt++;
    if(current == roopPos) break;
  }
  k -= cnt - roopcnt;
  k %= roopcnt;
  for(int i = 0; i < k; i++){
    current = a[current];
  }
  cout << current + 1 << endl;
}

Measured memory_bytes: 4840
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define repd(i, n) for (ll i = (n)-1; i >= 0; --i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - (a - b)) << endl;
}

Measured memory_bytes: 3604
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val s = br.readLine()!!
    val acgtSet = setOf('A', 'C', 'G', 'T')
    val ans = (s.indices).map {
        var tmp = 0
        for (i in it until s.length) {
            if (acgtSet.contains(s[i]) == false) break
            tmp++
        }
        tmp
    }.max()!!
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 40572
n = int(input())
s = input()
es = s.count('E')
e_cnt = 0
l = [0]*n
for i in range(n):
    left = i-e_cnt
    if s[i] == 'E':
        e_cnt +=1
    right = es - e_cnt
    l[i] = right+left

print(min(l))    

Measured memory_bytes: 15264
# coding: utf-8
import sys
from collections import defaultdict

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
dic = defaultdict(int)
for i, a in enumerate(A):
    x = a - i
    if x in dic:
        dic[x] += 1
    else:
        dic[x] = 1

answer = 0
for i, a in enumerate(A):
    y = a + i
    answer += dic[-y]
    x = a - i
    dic[x] -= 1

print(answer)


Measured memory_bytes: 137268
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	LL K;
	cin >> K;
	int N = 50;
	LL kai = K/N;
	vector<LL> A(N,kai+N-1);
	LL nokori = K%N;
	
	int pos = 0;
	while(nokori--){
		for(int i=0;i<N;++i){
			if( i == pos ){
				A[i] += N;
			}else{
				A[i]--;
			}
		}
		++pos;
	}
	cout << N << endl;
	for(int i=0;i<N;++i){
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
a,b,c = map(int,input().split())

if a == b:
  if a != c:
    print('Yes')
  else:
    print('No')
elif a == c:
  if a != b:
    print('Yes')
  else:
    print('No')
elif b == c:
  if b != a:
    print('Yes')
  else:
    print('No')
else:
  print('No')


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#define Mod 1000000007
using namespace std;
int fpow(int a,int b)
{
	int ans=1,t=a;
	while(b)
	{
		if(b&1)ans=(long long)ans*t%Mod;
		t=(long long)t*t%Mod;
		b>>=1;
	}
	return ans;
}
//2^a+...+2^{b-1}
int solve(int a,int b)
{
	return (fpow(2,b)-fpow(2,a)+Mod)%Mod;
}
int h[110],H[110];
int f[110][110];
void add(int& x,int y)
{
	x+=y;
	if(x>=Mod)x-=Mod;
	return ;
}
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&h[i]);
		H[i]=h[i];
	}
	H[0]=1;
	sort(H,H+n+1);int N=unique(H,H+n+1)-H;
	for(int i=1;i<=n;i++)
		h[i]=lower_bound(H,H+N,h[i])-H;
	f[0][1]=1;
	for(int i=1;i<=n;i++)
	{
		if(h[i]<=h[i-1]){
			for(int j=1;j<=h[i-1]+1;j++)
				if(j>h[i])add(f[i][h[i]+1],f[i-1][j]*2%Mod);
				else add(f[i][j],f[i-1][j]);
		}
		else{
			for(int j=1;j<=h[i-1];j++)
				add(f[i][j],(long long)f[i-1][j]*fpow(2,H[h[i]]-H[h[i-1]])%Mod);
			for(int j=h[i-1]+1;j<=h[i];j++)
				add(f[i][j],(long long)f[i-1][h[i-1]+1]*solve(H[h[i]]-H[j],H[h[i]]-H[j-1])*2%Mod);
			add(f[i][h[i]+1],f[i-1][h[i-1]+1]*2%Mod);
		}
//		printf("%d:",i);
//		for(int j=1;j<=h[i]+1;j++)
//			printf("%d ",f[i][j]);
//		printf("\n");
	}
	int ans=0;
	for(int i=1;i<=h[n]+1;i++)
		add(ans,f[n][i]);
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    vector<vector<int>> c(w);
    for (int i=0; i<w; i++)
        c[i].resize(h);

    for (int i=0; i<w; i++)
        for (int j=0; j<h; j++)
            c[i][j] = 0;


    for (int i=0; i<n; i++) {
        int x, y, a;
        cin >> x >> y >> a;

        if (a == 1) {
            for (int j=0; j<x; j++)
                for (int k=0; k<h; k++)
                    c[j][k] = 1;
        } else if (a == 2) {
            for (int j=x; j<w; j++)
                for (int k=0; k<h; k++)
                    c[j][k] = 1;
        } else if (a == 3) {
            for (int j=0; j<w; j++)
                for (int k=0; k<y; k++)
                    c[j][k] = 1;
        } else if (a == 4) {
            for (int j=0; j<w; j++)
                for (int k=y; k<h; k++)
                    c[j][k] = 1;
        }
    }

    int count = 0;
    for (int i=0; i<w; i++)
        for (int j=0; j<h; j++)
            if (c[i][j] == 0) count++;

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//Micro Futures scalping to get my tendies 
int main(){
	int a,b,c; cin>>a>>b>>c;
	int k; cin>>k; int co = 0;
	while(b <= a) { b *= 2; co++;}
	while(c <= b) { c *= 2; co++;}
	if(co <= k) cout<<"Yes\n";
	else cout<<"No\n";
	
	
}





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

int main(){
  	int N;
  	cin >> N;
  	for(int i=0; i<N; i++){
    	int A;
      	cin >> A;
      	if(A%2==0){
        	if(A%3==0 || A%5==0){
            }else{
            	cout << "DENIED" << endl;
              	return 0;
            }
        }
    }
  
  	cout << "APPROVED" << endl;
	return 0;
}

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

int main() {
  string n;
  cin >> n;
  int sum=0;
  int len = n.length();
  for(int i=0;i<len;i++)
    sum += n[i] - '0';
  if(sum%9==0)
    cout << "Yes";
  else
    cout << "No";
  
  return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	lli n,x,m;
	cin >> n >> x >> m;
	int k = 0;
	map <int,int> s;
	lli x1 = x;
	pair <lli,int> x2 = {x,-1};
//	for(int i = 0;i < m;++i){
//		cout << x1 << newl;
//		x1 = x1 * x1 % m;
//	}
	for(int i = 0;i < m;++i){
		if(s.find(x1) == s.end()){
			s[x1] = i;
		}
		else{
			x2 = {x1,s[x1]};
			break;
		}
		++k;
		x1 = x1 * x1 % m;
	}
	lli summ = 0;
	if(n <= x2.second){
		x1 = x;
		for(int i = 0;i < n;++i){
			summ = summ + x1;
			x1 = x1 * x1 % m;
		}
		cout << summ << newl;
		return;
	}
	n = n - x2.second;
	x1 = x;
	for(int i = 0;i < x2.second;++i){
		summ = summ + x1;
		x1 = x1 * x1 % m;
	}
	x1 = x2.first;
	k = k - x2.second;
	lli summ2 = 0;
	for(int i = 0;i < k;++i){
		summ2 = summ2 + x1;
		x1 = x1 * x1 % m;
	}
	summ = summ + summ2 * (n / k);
	x1 = x2.first;
	for(int i = 0;i < n % k;++i){
		summ = summ + x1;
		x1 = x1 * x1 % m;
	}
	cout << summ << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 5948
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string w = "aeiou";
    char c;
    cin >> c;
    if (w.find(c) != w.npos)
        cout << "vowel";
    else
        cout << "consonant";
}


Measured memory_bytes: 256
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N, M int

func main() {
	sc.Split(bufio.ScanWords)

	N, M = nextInt(), nextInt()
	m := make(map[int]int, N)
	// for i := 0; i < N; i++ {
	// 	m[i] = 0
	// }

	var a, b int
	for i := 0; i < M; i++ {
		a, b = nextInt()-1, nextInt()-1
		m[a]++
		m[b]++
	}

	for i := 0; i < N; i++ {
		fmt.Println(m[i])
	}

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	map<int,int> m;
	int res=1,ans=0,rem=0;
	for(int i=s.length()-1;i>=0;i--){
		rem=(rem%2019+((res)*(((int)s[i]-'0')%2019))%2019)%2019;
		res=(res*10)%2019;
		if(rem==0)
		ans++;
		ans+=m[rem];
		m[rem]++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3716
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
  const double PI = 3.14159265359;
  double r;
  cin >> r;
  cout << fixed << setprecision(5) << PI*r*r << " " << fixed << setprecision(6) << 2*r*PI << "\n";
  return 0;
}


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

int main()
{
    int cnt;
    string str;
    while (cin >> str && str != "0")
    {
        cnt = 0;
        for (int i = 0; i != str.size(); ++i)
        {
            cnt += str[i] - '0';
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3164
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.StringTokenizer;

public class Main {
	static HashMap<Integer, Integer> primefactors;
	static int mod = 1_000_000_007;
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//		BufferedReader br = new BufferedReader(new FileReader("input"));
		PrintWriter out = new PrintWriter(System.out);
		StringTokenizer st;
		st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		st = new StringTokenizer(br.readLine());
		primefactors = new HashMap<>();
		int a[] = new int[n];
		while(n-->0) {
			a[n] = Integer.parseInt(st.nextToken());	
			pf(a[n]);
		}
		long lcm = 1l;
		for(Entry<Integer, Integer>e:primefactors.entrySet()) {
			lcm *= pow(e.getKey(), e.getValue());
			lcm %= mod;
		}
		long ans = 0;
		for(int i:a) {
			ans += lcm*modInverse(i);
			ans %= mod;
		}
		out.println(ans%mod);
		out.flush();
	}
	static long modInverse(int a) {
		return pow(a,mod-2);
	}
	static long pow(long a,int n) {
	    long res=1;
	    while (n>0) {
	        if ((n-n/2*2)==1) {
	            res=res*a%mod;
	        }
	        a=a*a%mod;
	        n>>=1;
	    }
	    return res;
	}

 	static void pf(int n){
 		int cnt;
 		int l = n;
 		for(int i=2;i*i<=l;i++) {
 			cnt = 0;
 			while(n>1 && n%i == 0) {
 				cnt++;
 				n/=i;
 			}
 			if(cnt > 0)
 			{
 				primefactors.put(i, Math.max(cnt,primefactors.getOrDefault(i, 0)));
 			}
 		}
 		if(n>1)
 		{
 			primefactors.put(n, Math.max(1, primefactors.getOrDefault(n, 0)));
 		}
 	}
}


Measured memory_bytes: 26320
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;

typedef long long ll;
const ll mod=1e9+7;
const ll MAXN=20000+10;
const ll INF=0x7fffffff;

ll gra[210][210];
int n,m,r;
ll mn=INF;

int rtown[10];
bool vis[10];

void clean(){
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			if(i==j)//增加 
				continue;
			gra[i][j]=INF;
		}
	}
}

ll ans=INF;

void Floyd(){
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				gra[i][j]=min(gra[i][j],gra[i][k]+gra[k][j]);
			}
		}
	}
}

void dfs(int loc,int visit,ll pay){
	if(visit>=r){
		ans=min(ans,pay);
	}
	for(int i=1;i<=r;i++){
		if(vis[i]==true)	
			continue;
		int go=rtown[i];
		int now=rtown[loc];
		if(gra[now][go]==INF||gra[now][go]==0)
			continue;
		vis[i]=true;
		dfs(i,visit+1,pay+gra[now][go]);
		vis[i]=false;
	}
}

void print(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cout<<gra[i][j]<<" ";
		}
		cout<<endl;
	}
}
int main()
{
	scanf("%d %d %d",&n,&m,&r);
	clean();
	for(int i=1;i<=r;i++){
		scanf("%d",&rtown[i]);
	}
	for(int i=1;i<=m;i++){
		int x,y,cost;
		scanf("%d %d %d",&x,&y,&cost);
		if(gra[x][y]>cost){//增加 
			gra[x][y]=gra[y][x]=cost;
		} 
		
	}
	Floyd();
//	cout<<"图："<<endl;
//	print();
	for(int i=1;i<=r;i++){
		vis[i]=true;
		dfs(i,1,0);
		vis[i]=false;
	}
	
	cout<<ans<<endl;
	return 0;
}	 


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <cmath>
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define llong long long

int main() {
  char *a = (char*)malloc(sizeof(char)*82);
  size_t l = 0;
  while (getline(&a, &l, stdin) != EOF) {
    while(1) {
      int q = 0;//-1..out, 0..space, 1..t, 2..th, 3..the, 4...thi, 5..this, 6..tha, 7..that, 8..ok
      REP(j , (int)l-1) {
	if(a[j] == 'z') a[j] = 'a';
	else if(a[j] >= 'a' && a[j] < 'z') a[j]++;
      }
      REP(j , (int)l-1) {
	switch(q){
	case -1:
	  if(a[j] == ' ') q = 0;
	  break;
	case 0:
	  if(a[j] == 't') q = 1;
	  else q = -1;
	  break;
	case 1:
	  if(a[j] == 'h') q = 2;
	  else q = -1;
	  break;
	case 2:
	  if(a[j] == 'e') q = 3;
	  else if(a[j] == 'i') q = 4;
	  else if(a[j] == 'a') q = 6;
	  else q = -1;
	  break;
	case 3:
	  if(a[j] > 'z' || a[j] < 'a') q = 8;
	  else q = -1;
	  break;
	case 4:
	  if(a[j] == 's') q = 5;
	  else q = -1;
	  break;
	case 5:
	  if(a[j] > 'z' || a[j] < 'a') q = 8;
	  else q = -1;
	  break;
	case 6:
	  if(a[j] == 't') q = 7;
	  else q = -1;
	  break;
	case 7:
	  if(a[j] > 'z' || a[j] < 'a') q = 8;
	  else q = -1;
	  break;
	}
      }
      if(q == 8) break;
    }
    printf("%s",a);
    /*    REP(i , (int)l-1) {
      printf("%c",a[i]);
    }*/
  }
  return 0;
}

Measured memory_bytes: 2700
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

vector<vector<int>> ss;

int main(){
    cin.tie(0);

    Int N; cin >> N;
    Int S;
    int flag = 1;
    for (Int i = 1; i*(i-1) <= 2*N; i++){
        if (i*(i-1) == 2*N){
            cout << "Yes" << endl;
            S = i;
            flag = 0;
            break;
        }
    }
    if (flag){
        cout << "No" << endl;
        return 0;
    }
    int cnt = 1;
    ss = vector<vector<int>> (S);
    for (int i = 0; i < S; i++){
        for (int j = i+1; j < S; j++){
            ss[i].push_back(cnt);
            ss[j].push_back(cnt);
            cnt++;
        }
    }
    cout << ss.size() << endl;
    for (auto i : ss){
        cout << i.size() << " ";
        for (int j = 0; j < i.size(); j++){
            cout << i[j];
            if (j != i.size()-1) cout << " ";
        }
        cout << endl;
    }
        
}


Measured memory_bytes: 2304
#include <stdio.h>
int main(void) {
  int n;
  scanf("%d",&n);
  unsigned long a = 2;
  unsigned long b = 1;
  for(int i = 0;i < n-1;i++){
    unsigned long nxt = a + b;
    a = b;
    b = nxt;
  }
  printf("%lu",b);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
using namespace std;


int main(){
    int n,m;
    int a[20]={};
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    int dp[100000];
    for(int i=0;i<100000;i++){
        dp[i]=1000000;
    }
    dp[0]=0;
    dp[1]=1;
    
    
    for(int i=2;i<=n;i++){
        for(int t=0;t<m;t++){
            if(i-a[t]>=0){dp[i]=min(dp[i],dp[i-a[t]]+1);}
        }
    }
    
    cout<<dp[n]<<endl;
    
    return 0;
}



Measured memory_bytes: 3480
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"("<<(x).FI<<", "<<(x).SE<<")"<<endl;
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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


int main()
{
  int N; cin >> N;
  int A, B; cin >> A >> B;
  cout << min(A, B) << ' ';
  if (A + B >= N) cout << (A + B - N) << endl;
  else cout << 0 << endl;
  return 0;
}

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

typedef long long ll;

int N;
int A[200010],B[200010] = {0};
ll mod = 1000000007;
ll dp[4010][4010] = {0};
ll ans = 0;
ll F[8010],R[8010];

ll pow_mod(ll a,ll b)
{
    if(b == 0)return 1;
    ll res = pow_mod(a * a % mod,b / 2);
    if(b & 1)res = res * a % mod;
    return res;
}

ll con(ll a,ll b)
{
    return F[a] * R[b] % mod * R[a - b] % mod;
}

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)scanf("%d%d",A + i,B + i);

    for(int i = 0; i < N; i++)
    {
        dp[2001 - A[i]][2001 - B[i]]++;
    }
    for(int i = 1; i <= 4001; i++)
    {
        for(int j = 1; j <= 4001; j++)
        {
            dp[i][j] = (dp[i][j] + dp[i - 1][j] + dp[i][j - 1]) % mod;
        }
    }
    for(int i = 0; i < N; i++)
    {
        ans += dp[A[i] + 2001][B[i] + 2001];
        ans %= mod;
    }

    /*
    for(int i = 0; i < 8010; i++)
    {
        for(int j = 0; j <= i; j++)
        {
            if(j == 0)con[i][j] = 1;
            else con[i][j] = (con[i - 1][j] + con[i - 1][j - 1]) % mod;
        }
    }
    */

    F[0] = 1;
    for(int i = 1; i < 8010; i++)F[i] = F[i - 1] * i % mod;
    for(int i = 0; i < 8010; i++)R[i] = pow_mod(F[i],mod - 2);
    for(int i = 0; i < N; i++)
    {
        ans -= con(A[i] * 2 + B[i] * 2,A[i] * 2);
        ans = (ans + mod) % mod;
    }

    printf("%lld\n",ans * 500000004 % mod);
    return 0;
}


Measured memory_bytes: 127488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll dist[210][210];

int main() {
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;

  FOR(i,0,n-3){
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ++ans;
  }

  cout << ans << endl;
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

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

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

   return 0;
}


Measured memory_bytes: 4048