akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main (){
  int n;cin>>n;
  string w,s,t,v[n];
  for(int i=0;i<n;i++){
    cin>>w;v[i]=w;
  }
  for(int j=0;j<n;j++){
    for(int k=j+1;k<n;k++){
      if(v[j]==v[k]){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  for(int l=1;l<n;l++){
    s=v[l-1];t=v[l];
    if(s[s.length()-1]!=t[0]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> void chmax(Type_a &a,const Type_b &b){if(a<b)a=b;}
template<class Type_a,class Type_b> void chmin(Type_a &a,const Type_b &b){if(a>b)a=b;}
template<class Type> Type igcd(Type x,Type y){if(x==0||y==0)return (x>y)?x:y;return (y%x)?igcd(y%x,x):x;}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n,m;
	cin>>n>>m;
	
	vector<set<int> > vs(n+1);
	REP(i,m){
		int a,b;
		cin>>a>>b;
		vs[a].insert(b);
		vs[b].insert(a);
	}
	
	for(auto elem:vs[1]){
		if(vs[elem].count(n)){
			cout<<"POSSIBLE"<<endl;
			return 0;
		}
	}
	
	cout<<"IMPOSSIBLE"<<endl;
}

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

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> c(h);
    rep(i, h) cin >> c[i];

    int ans=0, cnt=0;
    for(int i=0; i<(1<<h); i++){
        for(int j=0; j<(1<<w); j++){
            cnt = 0;
            for(int m=0; m<h; m++){
                for(int n=0; n<w; n++){
                    if((i>>m) & 1) continue;
                    if((j>>n) & 1) continue;
                    if(c[m][n] == '#') cnt++;
                }
            }
            if(cnt == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <string.h>

int main(void)
{
  char str[10];
  int i,j,len,yes = 0,a = 100,c = 0;

  fgets(str,10,stdin);

  len = strlen(str);
  for(i = 0;i < len - 1;i++)
    {
      if(str[i] == 'A')
        {
          if(str[i+1] == 'C')
            {
              yes = 1;
              break;
            }
        }
    }

  if(yes == 1)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}


Measured memory_bytes: 128
import * as fs from 'fs'

const reader = (data: string) =>
  data
    .split('\n')
    .join(' ')
    .split(' ')
    .map(t => parseInt(t, 10))

function Main(input) {
  const [N] = reader(input)
  const genka = Math.floor((N + 0.999) / 1.08)
  if (N === Math.floor(genka * 1.08)) {
    console.log(genka)
  } else {
    console.log(':(')
  }
}

Main(fs.readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7500
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Scanner;
import java.util.Deque;
import java.util.ArrayDeque;


public class Main {	
    public static void main(String[] args) throws IOException{
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int depth = Integer.parseInt(br.readLine());
		Point p1 = new Point();
		Point p2 = new Point();	
		p1.set_point(0, 0);
		p2.set_point(100, 0);
		print_points(middle_three(p1, p2, depth));
		System.out.printf("%f %f\n", p2.x, p2.y);
    }
    
    public static Point[] middle_three(Point p1, Point p2, int depth){
    	if(depth == 0){
    		Point[] new_arr = {p1}; 
    		return new_arr;
    	}
    	
    	// return s, u, t
    	// calculate length

    	// pq_u_tilde = devide p1-p2 by 2 : (2*sqrt(3)-2)
    	// rotate pq_u_tilde for +30 deg 
    	// return middle_three(p1, s, depth) + middle_three(s, u) + middle_three(u, t) + middle_three(t, p2)
    	// [s, u, t]
    	
    	double l = Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
    	Point s = new Point();
    	Point u_tilde = new Point();
    	//Point u = null;
    	Point t = new Point();
    	
    	s.set_point(inter_division(p1.x, p2.x, 1, 2), inter_division(p1.y, p2.y, 1, 2));
    	t.set_point(inter_division(p1.x, p2.x, 2, 1), inter_division(p1.y, p2.y, 2, 1));
    	
    	u_tilde.set_point(inter_division(p1.x, p2.x, 2, 2*Math.sqrt(3)-2), 
    					  inter_division(p1.y, p2.y, 2, 2*Math.sqrt(3)-2)
    			);
    	Point u = rotate_line(p1, u_tilde, 30);
    	Point[] new_arr = two_arr2one(
    							two_arr2one(
    								two_arr2one(middle_three(p1, s, depth-1), middle_three(s, u, depth-1)), 
    								middle_three(u, t, depth-1) 
    								), middle_three(t, p2, depth-1)
    							);
    	return new_arr;
    }
    
    private static double inter_division(double x1, double x2, double a, double b){
    	return (x1 * b + x2 * a)/(a+b);
    }
    
    private static Point rotate_line(Point p1, Point p2, double deg){
    	// rotate vec(x->y)
    	deg = Math.toRadians(deg);
    	double x_rotated = (p2.x - p1.x) * Math.cos(deg) - (p2.y - p1.y) * Math.sin(deg) + p1.x;
    	double y_rotated = (p2.x - p1.x) * Math.sin(deg) + (p2.y - p1.y) * Math.cos(deg) + p1.y;
    	Point rotated_p2 = new Point();
    	//System.out.printf("rotated_line: %f, %f", x_rotated, y_rotated);
    	rotated_p2.set_point(x_rotated, y_rotated);

    	return rotated_p2;
    }
    private static Point[] two_arr2one(Point[] arr1, Point[] arr2){
    	Point[] one = new Point[arr1.length + arr2.length];
    	System.arraycopy(arr1, 0, one, 0, arr1.length);
    	System.arraycopy(arr2, 0, one, arr1.length, arr2.length);
    	return one;
    }
    
	public static void print_points(Point[] arr){
		for(Point element: arr){
			System.out.printf("%f %f\n", element.x, element.y);
		}
	}
}

class Point{
	double x;
	double y;
	void set_point(double p_x, double p_y){
		x = p_x;
		y = p_y;
	} 
}



Measured memory_bytes: 41728
import Control.Monad
import Data.Array.ST
import Data.Array.Unboxed

dex :: Int
dex = 1000000007

main :: IO ()
main = do
  [n,k] <- map read . words <$> getLine
  solve n k $ pascal n k
  
solve :: Int -> Int -> UArray (Int,Int) Int -> IO ()
solve n0 k0 b1 = forM_ [1..k0] $ \i -> print $ ((b1!(n0-k0+1,i)) * (b1!(k0-1,i-1))) `mod` dex

pascal :: Int -> Int -> UArray (Int,Int) Int
pascal n0 k0 = runSTUArray $ do
  dptbl <- newArray ((0,0),(n0,k0)) 0
  forM_ [(n',k') | n' <- [0..n0], k' <- [0..k0], n'>=k'] $ \(n,k) ->
    if k == 0 || k == n
    then writeArray dptbl (n,k) 1
    else liftM2 (\x y -> (x+y)`mod`dex) (readArray dptbl (n-1,k-1)) (readArray dptbl (n-1,k)) >>= writeArray dptbl (n,k)
  return dptbl


Measured memory_bytes: 32892
h,w=map(int, input().split())
a=[[i for i in input()] for j in range(h)]
q=[]
ans=-1
for i in range(h):
    for j in range(w):
        if(a[i][j]=="#"):
            q.append([i,j])
while len(q)>0:
    tl=q
    q=[]
    for i in tl:
        y=i[0]
        x=i[1]
        if(y>0):
            if(a[y-1][x]=="."):
                a[y-1][x]="#"
                q.append([y-1,x])
        if(x>0):
            if(a[y][x-1]=="."):
                a[y][x-1]="#"
                q.append([y,x-1])
        if(y<h-1):
            if(a[y+1][x]=="."):
                a[y+1][x]="#"
                q.append([y+1,x])
        if(x<w-1):
            if(a[y][x+1]=="."):
                a[y][x+1]="#"
                q.append([y,x+1])
    ans+=1
print(ans)

Measured memory_bytes: 179836
let input = require("fs").readFileSync("/dev/stdin", "utf8");
let cin = input.split(/ |\n/), cid = 0;
function next() { return +cin[cid++]; }
//input from catoonさん

function buffer(){
    // if (console._LOG_BUFFER) return;
// console._LOG_BUFFER = true;

  
var util = require('util');

var cache = {};

// make sure to flush at exit
process.on('exit', flush);

// export the flush and patch functions
module.exports = patch;
module.exports.flush = flush;

// save the original functions, and make a buffer for each
['warn', 'log', 'error', 'info'].forEach(function(name) {
  cache[name] = {
    func: console[name].bind(console),
    size: 0,
    buf: []
  };
});

// patch when required
patch();

/**
 * Patch the console.* commands with the given
 * limit (default 8k)
 */
function patch(limit?, pre?) {
  limit = limit || 8192; // 8kb

  // overwrite the console.* functions to buffer
  Object.keys(cache).forEach(function(name) {
    console[name] = function() {
      // format the input
      var s = util.format.apply(this, arguments);
      if (typeof pre === 'string') s = pre + s;
      else if (typeof pre === 'function') s = pre() + s;

      // calculate the new length
      var len = Buffer.byteLength(s);
      cache[name].size += len;

      // push the data, and flush if > limit
      cache[name].buf.push(s);
      if (cache[name].size > limit) flush();
    };
  });
}

/**
 * Flush all the caches by calling the original function forEach
 */
function flush() {
  // flush all caches
  Object.keys(cache).forEach(function(name) {
    // dump the buffer if present
    if (cache[name].size)
      cache[name].func(cache[name].buf.join('\n'));

    // clear the buffer
    cache[name].buf.length = 0;
    cache[name].size = 0;
  });
}
}
buffer();

class UnionFind {
    p: number[];
    sizes: number[];
    tmpsize: number;
    constructor(n: number) {
        this.p = Array(n);
        this.sizes = Array(n).fill(1);
        for (let i = 0; i < n; i++) {
            this.p[i] = i;
        }
        this.tmpsize = n;
    }
    find(x: number) {
        if (this.p[x] === x) {
            return x;
        } else {
            let tmp = this.find(this.p[x]);
            return tmp;
        }
    }
    unite(x: number, y: number) {
        let findx = this.find(x);
        let findy = this.find(y);
        if (findx === findy) return;

        let [large, small] = this.sizes[findx] >= this.sizes[findy] ? [findx, findy] : [findy, findx];

        this.p[small] = large;
        this.sizes[large] += this.sizes[small];
        this.tmpsize--;

    }
    is_same(x: number, y: number) {
        return this.find(x) === this.find(y);
    }
}
function main() {
    let n = next();
    let q = next();
    let uf = new UnionFind(n);
    while (q--) {
        let condition = next();
        let tmp = next();
        let tmp1 = next();
        if (condition === 0) {
            uf.unite(tmp, tmp1);
        }
        else {
            if (uf.is_same(tmp, tmp1)) {
                console.log(1);
            }
            else {
                console.log(0);
            }

        }
    }
    return;
}
main();


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

int n, sum, mi, a[105];
double avg, df, mn=1e9;
int main() {
	int i;
	cin >> n;
	for(i=0; i<n; i++) cin >> a[i], sum += a[i];
	avg = 1.0 * sum / n;
	for(i=0; i<n; i++) {
		df = abs(a[i] - avg);
		if(df < mn) mn = df, mi = i;
	}
	cout << mi;
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    vector<int> a;
    for(int i = 0; i < (int)s.size(); i++){
        if(s[i] == 'B') {
            if(a.empty()) continue;
            a.pop_back();
        }else a.push_back(s[i] - '0');
    }
    for(int i = 0; i < (int)a.size(); i++) cout << a[i];
    cout << endl;
    return 0;
}

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

using namespace std;

int main() {
	int k, a, b;
	cin >> k >> a >> b;
	if (b - a < 3) {
		cout << k + 1 << endl;
		return 0;
	}
	long n = max(0, k - a + 1) / 2;
	cout << n * (b - a) + k + 1 - n * 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)



ll xo(ll A){
  bool a[50];
  bool c[50]={};
  fr(i,50){
    a[i]=A%2;
    A/=2;
  }
  ifr(i,50){
    if(a[i]==0) continue;
    else c[i]=a[0];
  }
  ll ans=0;
  c[0]=a[1];
  fr(i,50){
    //cout<<i<<" "<<c[i]<<endl;
    ans+=c[i]*(1ll<<i);
  }
  return ans;
}

int main(){
  ll A,B;
  cin>>A>>B;
  cout<<(xo(B+1)^xo(A))<<endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>


int main()
{
    char c[3][3],i,j,k,l;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++){
            scanf("%c",&c[i][j]);
            }getchar();

    }
    printf("%c%c%c",c[0][0],c[1][1],c[2][2]);
    return 0;
}


Measured memory_bytes: 1660
program main
  implicit none
  integer :: n
  integer, allocatable :: d(:)
  read (*, *) n
  allocate (d(n))
  read (*, *) d
  call quicksort(d)
  write (*, "(i0)") d(n / 2 + 1) - d(n / 2)
  contains
  recursive subroutine quicksort(a)
    integer, intent(inout) :: a(:)
    integer :: pivot, i, j, k, tmp, n
    real(4) :: r
    n = size(a)
    if (n <= 1) return
    i = 1
    j = n
    call random_number(r)
    k = 1 + floor(r * n)
    k = max(1, min(k, n))
    pivot = a(k)
    do
      do while (.not. pivot <= a(i))
        i = i + 1
      end do
      do while (.not. a(j) <= pivot)
        j = j - 1
      end do
      if (i >= j) exit
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
      i = i + 1
      j = j - 1
    end do
    call quicksort(a(1:i - 1))
    call quicksort(a(j + 1:n))
  end subroutine quicksort
end program main


Measured memory_bytes: 1152
import itertools
while True:
    n,x = map(int,input().split())
    if n == 0 and x == 0:
        exit()
    num = [ i for i in range(1,n+1)]
    ans = 0
    for i in itertools.combinations(num,3):
        if sum(i) == x:
            ans += 1
    print(ans)


Measured memory_bytes: 5644
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int a[2000];
int n;

int main(){
  cin>>n;
  REP(i,n)
    cin>>a[i];
  bitset<4000000> b;
  b[0]=true;
  LL gr = accumulate(a,a+n,0);
  REP(i,n){
    b|=b<<a[i];
  }
  FOR(i,(gr+1)/2,gr+1){
    if(b[i]){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    char s[11];
    scanf("%s", s);
    for(int i = 0; i < 4; i++){
        if(s[i]==0){
            printf("No");
            return 0;
        }
    }
    if((s[0] == 'Y') && (s[1] == 'A') && (s[2] == 'K') && (s[3] == 'I')){
        printf("Yes");
        return 0;
    }
    printf("No");
    return 0;
}


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

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

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

    vector<int> c(n);
    vector<int> r_num(n + 1, 0);
    vector<int> g_num(n + 1, 0);
    vector<int> b_num(n + 1, 0);
    rep(i, n) {
        r_num[i + 1] = r_num[i];
        g_num[i + 1] = g_num[i];
        b_num[i + 1] = b_num[i];
        if (s[i] == 'R') {
            c[i] = 0;
            r_num[i + 1] = r_num[i] + 1;
        }
        else if (s[i] == 'G') {
            c[i] = 1;
            g_num[i + 1] = g_num[i] + 1;
        }
        else {
            c[i] = 2;
            b_num[i + 1] = b_num[i] + 1;
        }
    }

    ll ans = 0;
    for (int i = 0; i < n-2; i++) {
        for (int j = i + 1; j < n-1; j++) {
            if (c[i] == c[j]) continue;
            if (c[i] + c[j] == 1) {  // RGのとき
                ans += b_num[n] - b_num[j + 1];
                if (2*j - i < n) {
                    if (c[2 * j - i] == 2) ans -= 1;
                }
            }
            else if (c[i] + c[j] == 3) {  // GBのとき
                ans += r_num[n] - r_num[j + 1];
                if (2 * j - i < n) {
                    if (c[2 * j - i] == 0) ans -= 1;
                }
            }
            else {  // RBのとき
                ans += g_num[n] - g_num[j + 1];
                if (2 * j - i < n) {
                    if (c[2 * j - i] == 1) ans -= 1;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define ll long long
#define pb push_back

int millennium(int y, int m, int d){
    // 一年
    int yd = 20*5 + 19*5;
    int biy = (y-1)/3;
    int bim = (m-1)/2;
    int a = yd*(y-1) + biy*5 + (m-1)*20 - bim + d;
    if(y%3==0){
        a += bim;
    }
    // cout << a << endl;
    return a;
}

int main()
{
    int y, m, d, n;
    vector<int> x;
    int allDay = millennium(1000,1,1);

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> y >> m >> d;
        int a = millennium(y,m,d);
        x.push_back(allDay-a);
    }

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



Measured memory_bytes: 3124
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD (1e9+7)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> vvi;

class union_find{
public:
    vector<int> parent;
    union_find(int n) : parent(vector<int>(n, -1)) {} //Parent is -(size of set)
    int root(int a){ return (parent[a] < 0 ? a : parent[a] = root(parent[a])); }
    int size(int a){ return -parent[root(a)]; }
    bool same(int &a, int &b){a=root(a);b=root(b); return (a==b); }
    bool connect(int a, int b){
        if(same(a,b)) return false;
        if(size(a)<size(b)) a^=b^=a^=b;
        parent[a] += parent[b]; parent[b]=a;
        return true;
    }
};

int kruskal(int v, vector<pair<int, pii>> &g){
    union_find uf(v);
    SORT(g);
    int ans = 0;
    for(int i = 0; i < g.size(); i++){
        if(!uf.same(g[i].second.first, g[i].second.second)){
            ans += g[i].fi;
            uf.connect(g[i].second.first, g[i].second.second);
        }
    }
    return ans;
}

int main(void)
{
    int v,e;
    cin >> v >> e;
    vector<pair<int, pii>> g(e);
    REP(i, e){
        int s,t,w;
        cin >> s >> t >> w;
        g[i].fi = w;
        g[i].se.fi = s;
        g[i].se.se = t;
    }

    pr(kruskal(v,g));
}


Measured memory_bytes: 4124
#include <iostream>

using namespace std;

int main()
{
int a;
int b;
cin>>a;
cin>>b;
if(a == 1 && b==2 || a==2 &b==1){

    cout<<"3";
} else if(a == 2 && b==3 || a==3 &b==2){
cout<<"1";
} else{
cout<<"2";
}
}


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

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;

  ll p[A], q[B], r[C];
  ll tmp;
  rep(i,A) {
    cin >> p[i];
  }
  sort(p, p+A);
  reverse(p, p+A);

  rep(i,B) {
    cin >> q[i];
  }
  sort(q, q+B);
  reverse(q, q+B);

  rep(i,C) {
    cin >> r[i];
  }
  sort(r, r+C);
  reverse(r, r+C);

  vector<int> d;
  rep(i,X) {
    d.push_back(p[i]);
  }
  rep(i,Y) {
    d.push_back(q[i]);
  }
  rep(i,C) {
    d.push_back(r[i]);
  }
  sort(d.rbegin(), d.rend());

  ll sum = 0;
  rep(i,X+Y) {
    sum += d[i];
  }

  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf (ll)(1e18)
#define mod 1000000007


int main()
{
    int t=1;
    //cin>>t;
    while( t-- )
    {
        string s;
        cin>>s;
        ll ans=0;
        for( ll i=0 ; i<s.size() ; i++ )
        {
            ans+=s[i]-'0';
        }

        if( ans%9==0 )
            cout<<"Yes";
        else
            cout<<"No";
    }

    return 0;
}












Measured memory_bytes: 3588
import scala.io.StdIn._

object Main extends App {
  val Array(a, b, x) = readLine.split(" ").map(_.toDouble)
  val limitTan = b / a
  val limitArea = x / a

  def area(rad: Double): Double = Math.tan(rad) match {
    case tan if tan > limitTan => 1 / tan * b * b / 2
    case tan => a * b - a * a * tan / 2
  }
  def angle(rad: Double): Double = rad * 180 / Math.PI

  def binSearch(min: Double, max: Double, cnt: Int): Double = {
    val mid =(max + min) / 2
    if (cnt == 0) mid
    else {
      if (area(mid) < limitArea) binSearch(min, mid, cnt - 1)
      else binSearch(mid, max, cnt - 1)
    }
  }

  println(angle(binSearch(0, Math.PI / 2, 50)))
}

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

int fact(int x) {
  int y = 1;
  for(int i=1; i<=x; i++) y *= i;
  return y;
}

int main() {
  int n;
  cin >> n;
  
  vector<int> p(n);
  for(int i=0; i<n; i++) cin >> p[i];
  vector<int> q(n);
  for(int i=0; i<n; i++) cin >> q[i];
  
  int a=1;
  vector<int> num = {1,2,3,4,5,6,7,8};
  for(int i=n; i>0; i--) {
    int k, cnt=0;
    for(int j=0; j<n; j++) {
      if(num[j]==p[n-i]) {
        k = cnt;
        num[j] = 0;
        break;
      }
      if(num[j]!=0) cnt++;
    }
    a += k*fact(i-1);
  }
  
  int b=1;
  num = {1,2,3,4,5,6,7,8};
  for(int i=n; i>0; i--) {
    int k, cnt=0;
    for(int j=0; j<n; j++) {
      if(num[j]==q[n-i]) {
        k = cnt;
        num[j] = 0;
        break;
      }
      if(num[j]!=0) cnt++;
    }
    b += k*fact(i-1);
  }
  
  cout << abs(a-b) << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
int A[100010];
int main() {
	deque<int> dq = {1};
	int K;
	cin >> K;
	rep(i, 100001) A[i] = 10000000;
	int p;
	A[1] = 1;
	while(dq.size()) {
		p = dq.front();
		dq.pop_front();
		if (A[(p + 1) % K] > A[p] + 1){
			A[(p + 1) % K] = A[p] + 1;
			dq.push_back((p + 1) % K);
		}
		if (A[(p * 10) % K] > A[p]) {
			A[(p * 10) % K] = A[p];
			dq.push_front((p * 10) % K);
		}
	}
	cout << A[0];
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    priority_queue<P> pq;
    for (int i = 0; i < N; ++i) {
        cin >> B[i];
        pq.push(P(B[i], i));
    }
    ll ans = 0;
    while (!pq.empty()) {
        P now = pq.top();
        pq.pop();
        ll now_b = now.first;
        int idx = now.second;
        ll sum = B[(idx - 1 + N) % N] + B[(idx + 1) % N];
        if (now_b < sum) continue;
        ll cnt = (now_b - A[idx]) / sum;
        if (cnt == 0) continue;
        now_b -= cnt * sum;
        B[idx] = now_b;
        ans += cnt;
        if (now_b > A[idx]) pq.push(P(now_b, idx));
    }
    for (int i = 0; i < N; ++i) {
        if (A[i] != B[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9328
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int ans = 0;
ll n;

void dfs(ll num) {
    if (num > n) return;
    string s = to_string(num);
    bool three = false, five = false, seven = false;
    rep(i, s.length()) {
        if (s[i] == '3') three = true;
        if (s[i] == '5') five = true;
        if (s[i] == '7') seven = true;
    }
    if (three && five && seven) ans++;
    dfs(num*10 + 3);
    dfs(num*10 + 5);
    dfs(num*10 + 7);
}

int main() {
    cin >> n;
    dfs(3);
    dfs(5);
    dfs(7);

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

Measured memory_bytes: 256
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<string> S;

  if (S.back() == '?')
    S.back() = 'D';
  
  for (int i = S.length()-2; i>=1;i--) {
    if (S[i] == '?')
    S[i] = (S[i+1] == 'D' && S[i-1] != 'P') ? 'P' : 'D';
  }
  
  if (S.length()>=2 && S[0] == '?')
    S[0] = (S[1] == 'D') ? 'P' : 'D';


  return S;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 3720
#include <stdio.h>
#include <string.h>
int main(void){
 char al[101];
 int i,j=0;
 int a[26];
 for(i=0;i<26;i++) a[i]=0;
 scanf("%s",al);
 for(i=0;i<strlen(al);i++) a[al[i]-'a']++;
 for(i=0;i<26;i++) j+=(a[i]%2);
 printf(j==0?"Yes":"No");
 return 0;
}

Measured memory_bytes: 128
/**
 *      ABC 92 C
 *      author  : kyomukyomupurin
 *      created : 2018-08-30 18:20:12
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    vector<int> v;
    for (int i = 0; i < N; ++i) {
        int x; cin >> x;
        v.push_back(x);
    }

    int sum = 0;

    for (int i = 1; i < N; ++i) {
        sum += abs(v[i - 1] - v[i]);
    }
    sum = sum + abs(0 - v[0]) + abs(v[N - 1] - 0);//全部回ったときのコスト

    vector<int> diff;//iをスキップしたときに浮くコスト
    diff.push_back(abs(0 - v[0]) + abs(v[0] - v[1]) - abs(0 - v[1]));
    for (int i = 1; i < N - 1; ++i){
        diff.push_back(abs(v[i - 1] - v[i]) + abs(v[i] - v[i + 1]) - abs(v[i - 1] - v[i + 1]));
    }
    
    diff.push_back(abs(v[N - 2] - v[N - 1]) + abs(v[N - 1] - 0) - abs(v[N - 2] - 0));
    
    for (int i = 0; i < N; ++i) {
        cout << sum - diff[i] << '\n';
    }
    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  lli n;
  while (cin >> n) {
    const int N = 70;
    const int M = 20;
    const lli mod = 1e9 + 7;
    lli dp[N][M];
    fill(&dp[0][0], &dp[N - 1][M - 1] + 1, 0);
    dp[0][0] = 1;

    // cout << ">>>> " << n << endl;
    
    vector<int> v;
    for (lli i = 1; i <= n; i *= 2LL) {
      v.push_back((bool)(n & i));
    }
    reverse(v.begin(), v.end());

    for (int nth = 0; nth < v.size(); ++nth) {
      for (int i = 0; i < 3; ++i) {
        for (int a = 0; a < 2; ++a) {
          for (int b = 0; b < 2; ++b) {
            if (a && !b) continue;
            const int j = i * 2 + v[nth] - a - b;
            if (0 <= j) {
              (dp[nth + 1][min(j, 2)] += dp[nth][i]) %= mod;
            }
          }
        }
      }
    }
    lli sum = dp[v.size()][0] + dp[v.size()][1] + dp[v.size()][2];
    sum %= mod;
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
if a <= c:
    if b <= d:
        if b < c:
            print(0)
        else:
            print(b-c)
    else:
        print(d-c)
else:
    if b > d:
        if a < d:
            print(d-a)
        else:
            print(0)
    else:
        print(b-a)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
using namespace std;
void trace(int A[],int N){
    int i;
    for(i=0;i<N;i++){
        if(i>0){
            cout<<" ";
        }cout<<A[i];
    }cout<<endl;
}

void insertionSort(int A[],int N){
    int j,i,v;
    for(i=1;i<N;i++){
        v=A[i];
        j=i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        trace(A,N);
    }
}
int main(){
    int N,i,j;
    int A[100];
    
    cin>>N;
    for(i=0;i<N;i++){
        cin>>A[i];
    }
    trace(A,N);
    insertionSort(A,N);
    
    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  int answer = 0;
  int i = 0;
  
  while(n >= pow(2, i))
  {
    answer++;
    i++;
  }
  
  cout << pow(2, answer - 1) <<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N=3000005;
int flag[N],ne[N][3],cnt,n,fac[N],v[N],ans[N],ss;
char s[N];
void build(){
int last1=0,last2=0;
for (int i=0;i<n;i++){
for (int j=last1;j<=last2;j++){
ne[j][0]=++cnt;
v[cnt]=v[j];
ne[j][1]=++cnt;
v[cnt]=v[j]+fac[i];
ne[j][2]=++cnt;
v[cnt]=v[j]+fac[i]*2;
}
last2+=fac[i+1];last1+=fac[i];
}
}
void down(int x){
if (flag[x]){
swap(ne[x][1],ne[x][2]);
if (ne[x][0])flag[ne[x][0]]^=1,flag[ne[x][1]]^=1,flag[ne[x][2]]^=1;
flag[x]=0;
}
}
void insert1(int x){
down(x);
swap(ne[x][0],ne[x][1]);
swap(ne[x][0],ne[x][2]);
if (ne[x][0])x=ne[x][0],insert1(x);
}
void solve(int x,int t,int d){
down(x);
if (ne[x][0])solve(ne[x][0],t,d+1),solve(ne[x][1],t+fac[d],d+1),solve(ne[x][2],t+2*fac[d],d+1);
else ans[v[x]]=t;
}
int main(){
scanf("%d",&n);
scanf("%s",s+1);
fac[0]=1;ss=0;
for (int i=1;i<=n;i++)fac[i]=fac[i-1]*3;
for (int i=0;i<n;i++)ss+=fac[i];
build();
for (int i=1;s[i];i++){
if (s[i]=='R')insert1(0);
else flag[0]^=1;
}
solve(0,0,0);
for (int i=0;i<fac[n];i++)printf("%d ",ans[i]);
}

Measured memory_bytes: 21884
N = int(input())
A = list(map(int,input().split()))
S = [0]
for i in range(N):  S.append(S[-1] + A[i])
ans = 0
dic = {}
for data in S:
    if data in dic:  
        ans += dic[data]
        dic[data] += 1
    else:  dic[data] = 1
print(ans)

Measured memory_bytes: 136812
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int sum;
  int m=1000000;
  int diff='0';
  cin>>s;
  for(int i=0;i<s.size()-2;i++){
    sum=(s[i]-diff)*100+(s[i+1]-diff)*10+(s[i+2]-diff);
    int a=abs(753-sum);
    m=min(a,m);
  }
  cout<<m<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int num[N];
  for(int i = 0;i<N;i++){
    cin >> num[i];
  }
  int mi = 10000,ma = 0;
  for(int k = 0;k<N;k++){
    mi = min(mi,num[k]);
    ma = max(ma,num[k]);
  }
  cout << ma -mi  << 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 t = sc.nextInt();
    while(t-->0){
      long a = sc.nextLong();
      long b = sc.nextLong();
      long c = sc.nextLong();
      long d = sc.nextLong();
      if(a-b<0){
        System.out.println("No");
        continue;
      }
      else{
        if(b>d){
          System.out.println("No");
          continue;
        }
        else if(c+1>=b){
          System.out.println("Yes");
          continue;
        }
      }
      long p = gcd(b,d);
      if((a-c-1)/p>(a-b)/p)System.out.println("No");
      else System.out.println("Yes");
    }
  }
  public static long gcd(long x, long y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}

Measured memory_bytes: 25032
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
// *max_element(all(d))
int solve(){
  int n;
  cin >> n;
  int k = 0,sum = 0;
  while(sum < n)sum += (++k);
  int dif = sum - n;
  REP(i,1,k+1)if(i!=dif)cout << i << endl;
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
/** Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k,i,j;
    cin>>n>>k;
    long long int h[n],dp[n];
    for(i=0;i<n;++i)    cin>>h[i];
    dp[0] = 0;
    //cout<<"0 ";
    for(i=1;i<n;++i)    dp[i] = pow(10,10);
    for(i=1;i<n;++i)
    {
        for(j=i-1;j>=(i-k) && j>=0;--j)
        {
            dp[i] = min(dp[i] , dp[j]+abs(h[i]-h[j]));
        }
        //cout<<dp[i]<<" ";
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>

using namespace std;

int INF = 10000000;

string memo[1000];
int memoMax = 0;

int setstr(string str)
{
	for(int i = 0;i < memoMax;i++)
	{
		if(str == memo[i] )return 0;
	}
	memo[memoMax++] = str;
	return 1;
}

string strrev(string str)
{
	for(int i = 0;i < str.length()/2;i++)
	{
		char c = str[i];
		str[i] = str[str.length() - i - 1]; 
		str[str.length() - i - 1] = c;
	}
	return str;
}


int cast(string str)
{
	int len = str.length();

	int sum = 0;
	sum+=setstr(str);

	for(int i = 1;i < len;i++)
	{
		string str1 = str.substr(0,i);
		string str2 = str.substr(i,len-i);


		sum+=setstr(str1+strrev(str2));
		sum+=setstr(strrev(str1)+str2);
		sum+=setstr(strrev(str1)+strrev(str2));

		sum+=setstr(str2+str1);
		sum+=setstr(str2+strrev(str1));
		sum+=setstr(strrev(str2)+str1);


	}

	sum+=setstr(strrev(str));

	memoMax = 0;

	return sum;
} 


int main()
{
	int m;
	string str;

	cin >> m;


	for(int i = 0;i < m;i++)
	{

		cin >> str;
 
	
		cout << cast(str) << endl;
	
	}

  return 0;
}

Measured memory_bytes: 1288
#include<bits/stdc++.h>
using namespace std;
#define SC scanf
#define PR printf
#define pb push_back
#define mp make_pair
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define INF 1000000000
#define ll long long
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef pair<pii,pii> ppp;
typedef vector<int> vi;
typedef vector<pii> vii;
const int xx[4]={1,-1,0,0};
const int yy[4]={0,0,1,-1};
multiset<int>ms;
int main(){
    ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int t;
		cin>>t;
		ms.insert(t);
	}
	int ans=0;
	while(!ms.empty()){
		multiset<int>::iterator it=ms.end();
		it--;
		int x=*it;
		ms.erase(it);
		int i;
		for(i=1;i<=x;i*=2);
		if(ms.find(i-x)!=ms.end()){
			ans++;
			ms.erase(ms.find(i-x));
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9600
N = int(input())
S = list(input())
ans = 0
for i in range(1,N):
    a=0
    s1 = list(set(S[:i+1]))
    s2 = list(set(S[i+1:]))
    for j in range(len(s2)):
        a += list(set(s1)).count(s2[j])
    ans = max(ans, a)

print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

bool is_haiku_found(const vector<ll> &len, ll idx)
{
    ll a = 0;
    for (; idx < len.size(); ++idx) {
        a += len[idx];
        if (a == 5)break;
        else if (a > 5)return false;
    }
    ll b = 0;
    for (++idx; idx < len.size(); ++idx) {
        b += len[idx];
        if (b == 7)break;
        else if (b > 7)return false;
    }
    ll c = 0;
    for (++idx; idx < len.size(); ++idx) {
        c += len[idx];
        if (c == 5)break;
        else if (c > 5)return false;
    }
    ll d = 0;
    for (++idx; idx < len.size(); ++idx) {
        d += len[idx];
        if (d == 7)break;
        else if (d > 7)return false;
    }
    ll e = 0;
    for (++idx; idx < len.size(); ++idx) {
        e += len[idx];
        if (e == 7)break;
        else if (e > 7)return false;
    }
    return
        a == 5 &&
        b == 7 &&
        c == 5 &&
        d == 7 &&
        e == 7;
}
int main()
{
    while (true) {
        ll n = in();
        if (n == 0)break;
        vector<ll>len(n);
        REP(i, n)len[i] = in<string>().length();
        REP(i, n) {
            if (is_haiku_found(len, i)) {
                cout << i + 1 << endl;
                break;
            }
        }
    }
}


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

int main(){
    int a,b,c,t;
    cin>>a;
    cin>>b;
    cin>>c;
    if(a>b){
        t=a;a=b;b=t;
    }
    if(a>c){
        t=a;a=c;c=t;
    }
    if(b>c){
        t=b;b=c;c=t;
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


Measured memory_bytes: 3060
N,T = (int(i) for i in input().split())
cts = [[int(i) for i in input().split()] for i in range(N)]

nums=[]
for ct in cts:
    if ct[1] > T:
        continue
    nums.append(ct[0])
if len(nums) == 0:
    print("TLE")
else:
    print(min(nums))


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

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    for(int i = 0; i < 10000; i++){
        if((x-a) - i * b < 0){
            cout << (x-a) - (i-1) * b << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;

using matrix = vector<vector<ll>>;
ll N;

matrix mul(matrix &A,matrix &B){
    matrix C(N, vector<ll>(N, 0));
    for(ll i=0;i<N;++i){
        for(ll j=0;j<N;++j){
            ll s=0;
            for(ll k=0;k<N;++k){s+=A[i][k]*B[k][j];s%=MOD;}
            C[i][j]=s;
        }
    }
    return C;
}

matrix pow(matrix &A, ll n){
    matrix origin(N, vector<ll>(N, 0));
    for(ll i=0;i<N;++i)origin[i][i]=1;
    matrix K=A;
    while(n){
        if(n&1LL){
            origin=mul(origin,K);
        }
        K=mul(K,K);
        n>>=1;
    }
    return origin;
}



signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    cin >> N;
    ll K;
    cin >> K;
    vector<vector<ll>> A(N, vector<ll>(N, 0));
    for(ll i=0;i<N;++i)
        for(ll j=0;j<N;++j)cin>>A[i][j];
    matrix ANS=pow(A,K);
    ll ans=0;
    for(ll i=0;i<N;++i)
        for(ll j=0;j<N;++j)ans+=ANS[i][j];


    prt(ans%MOD)fl
    


    return 0;
}


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

int main()
{
    int a, b, c, d, e;
    cin>>a>>b;
    c = a + b;
    d = a - b;
    e = a * b;
    if(c >= d)
    {
        if(c >= e)
            cout<<c<<endl;
        else
            cout<<e<<endl;
    }
    else
    {
        if(d >= e)
            cout<<d<<endl;
        else
            cout<<e<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
using P = pair<int, int>;
const ll inf = 1e9;
const int MAX = 1e5+5;
const ll MOD = 1e9+7;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long 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] % MOD) % MOD;
}

int main(){
    COMinit();
    ll n, k; cin >> n >> k;
    ll ans = 0;
    vector<ll> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for(int i=k-1; i<n; i++){
        ans += (a[i] - a[n-i-1]) * COM(i, k-1);
        ans = ans % MOD;
    }
    cout << ans << endl;
    return 0;
}

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

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

    for(int i = 0; i < s.length(); i++){
        if(s == t){
            cout << "Yes" << endl;
            return 0;
        }
        s.insert(s.begin(),s.back());
        s.pop_back();
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
// Charan Sriramula

#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;

const ll logx=30;
const ll N=1e5+5;
const ll M=1e3+5;
const ll mod=1e9+7;
const ll INF=1e18+5;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)

inline ll mul(ll a, ll b,ll p){ return (a * 1ll * b) % p; }
inline ll sub(ll a, ll b,ll p){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll add(ll a, ll b,ll p){ ll c = a + b; if(c > p) c -= p; return c; }

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

ll n, m, maxi;
string s[2005];
ll bot[2005][2005],top[2005][2005],lef[2005][2005],rig[2005][2005];

int main(){
  cin>>n>>m;
  for(int  i = 0; i < n; i++){
    cin>>s[i];
  }
  for(int i=0;i<m;i++){
    ll maxx;
    if(s[0][i]=='.'){maxx=-1;}
    else{maxx=0;}
    for(int j=0;j<n;j++){
      if(s[j][i]=='#'){maxx=j;}
      top[j][i]=maxx;
    }
  }
  for(int i=m-1;i>=0;i--){
    ll maxx;
    if(s[n-1][i]=='.'){maxx=n;}
    else{maxx=n-1;}
    for(int j=n-1;j>=0;j--){
      if(s[j][i]=='#'){maxx=j;}
      bot[j][i]=maxx;
    }
  }
  for(int i=0;i<n;i++){
    ll maxx;
    if(s[i][0]=='#'){maxx=0;}
    else{maxx=-1;}
    for(int j=0;j<m;j++){
      if(s[i][j]=='#'){maxx=j;}
      lef[i][j]=maxx;
    }
  }
  for(int i=0;i<n;i++){
    ll maxx;
    if(s[i][m-1]=='#'){maxx=m-1;}
    else{maxx=m;}
    for(int j=m-1;j>=0;j--){
      if(s[i][j]=='#'){maxx=j;}
      rig[i][j]=maxx;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(s[i][j]=='#'){
        continue;
      }
      ll lans=j-lef[i][j];
      ll rans=rig[i][j]-j;
      ll uans=i-top[i][j];
      ll dans=bot[i][j]-i;
      maxi=max(maxi,lans+rans+uans+dans-3);
      //trace6(i,j,lans,rans,uans,dans);
    }
  }
  cout<<maxi<<endl;
  /*for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cout<<rig[i][j]<<" ";
    }
    cout<<endl;
  }*/
}


Measured memory_bytes: 129920