akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define cmin(a,b)(a>(b)?a=(b),1:0)
#define cmax(a,b)(a<(b)?a=(b),1:0)
#define dmin(a,b)((a)<(b)?(a):(b))
#define dmax(a,b)((a)>(b)?(a):(b))
namespace io{
	int F(){
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'
			&&(ch<'0'||ch>'9'));
			ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'
		&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
}
int fa[222222],siz[222222],pno,f[222222];
long long add[222222];

int gf(int u){
	if(fa[u]==u)return u;
	return fa[u]=gf(fa[u]);
}

struct edg{
	int x,y,l;
}ed[555555];

bool operator <(const edg &x,const edg &y)
{
	return x.l>y.l;
}

int main(){
	int n=io::F(),m=n-1;
	for(register int i=1;i<=m;++i)
		ed[i]=(edg){io::F(),io::F(),io::F()};
	std::sort(ed+1,ed+m+1);
	pno=n;
	for(register int i=1;i<=n;++i)
		fa[i]=i,siz[i]=1;
	for(register int i=1;i<=m;++i){
		int t1=gf(ed[i].x),t2=gf(ed[i].y);
		if(t1==t2)continue;
		add[t1]=siz[t2]*(long long)ed[i].l;
		add[t2]=siz[t1]*(long long)ed[i].l;
		f[t1]=f[t2]=fa[t1]=fa[t2]=++pno;
		siz[pno]=siz[t1]+siz[t2];
		fa[pno]=pno;
	}
	for(register int i=pno-1;i;--i)
		add[i]+=add[f[i]];
	for(register int i=1;i<=n;++i)
		printf("%lld\n",add[i]);
	return 0;
}

Measured memory_bytes: 7552
package main

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

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sup := 1000000000
	s, _ := strconv.Atoi(read())

	var a, b int
	if s%sup == 0 {
		a = s / sup
		b = 0
	} else {
		a = s/sup + 1
		b = sup - s%sup
	}

	fmt.Printf("0 0 %d 1 %d %d\n", sup, b, a)
}


Measured memory_bytes: 640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main(){
    input!{
        a: i64,
        b: i64
    }
    println!("{}", if a*b % 2 == 0 {"Even"} else {"Odd"});
}


Measured memory_bytes: 4352
import sys
s=[list(map(int,e.split(',')))for e in sys.stdin]
for i in range(1,len(s)):
 k=len(s[i])
 for j in range(k):
  t=j-(k>len(s[i-1]))
  s[i][j]+=max(s[i-1][t*(j>0):t+2])
print(*s[-1])


Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>

using std::cout;
using std::cin;

void oneCase () {
    int a;
    cin >> a;
    for (int x = 1; x < 10; ++x) {
        if (a % x == 0 && a / x < 10) {
            cout << "Yes" << "\n";
            return;
        }
    }
    cout << "No" << "\n";
}


int main() {
    int k = 1;
//    cin >> k;
    for (int i = 0; i < k; ++i) {
        oneCase();
    }

    return 0;
}

Measured memory_bytes: 256
n,k,c=map(int,input().split())
s=input()
if k==1:
  if s.count("o")==1:
    print(s.index("o")+1)
  exit()
l=[-c]*k
r=[n+c]*k
ll=0
for i in range(n):
  if ll==0:
    if s[i]=="o":
      l[ll]=i
      ll+=1
    continue 
  if s[i]=="x" or l[ll-1]+c>=i:continue
  l[ll]=i
  ll+=1
  if ll==k:break
rr=k-1
for i in range(n):
  if rr==k-1:
    if s[(n-1)-i]=="o":
      r[rr]=(n-1)-i
      rr-=1
    continue
  if s[(n-1)-i]=="x" or r[rr+1]-c<=(n-1)-i:continue
  r[rr]=(n-1)-i
  rr-=1
  if rr==-1:break
for i in range(k):
  if l[i]==r[i]:print(l[i]+1)

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

using ll=long long;

const ll mod=1000000007LL;

inline ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
inline ll ADD(const ll &a, const ll &b,const ll &mod) { return a+b<mod?a+b:a+b-mod;}
inline ll SUB(const ll &a, const ll &b,const ll &mod) { return a-b>=0?a-b:a-b+mod;}
inline ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
inline ll INV(ll a,ll mod){ll x,y;extgcd(a,mod,x,y);return (x%mod+mod)%mod;}
inline ll DIV(const ll &a, const ll &b,const ll &mod) {return MUL(a,INV(b,mod),mod);}
inline ll POW(ll a,ll n,ll mod){ll b=1LL;for(a%=mod;n;a=MUL(a,a,mod),n>>=1)if(n&1) b=MUL(b,a,mod); return b;}

const char base='a'-1;

ll memo[64][64][32][32];
string s[55];

ll rec(ll l,ll r,ll p,ll c){
	ll &ret=memo[l][r][p][c];
	if(ret>=0) return ret;
	if(l>=r) return ret=1LL;
	
	ret=0LL;
	if(c==27) return ret=0;  
	if(p==20) return ret=(r-l)==1;

	for(ll i=l;i<=r;++i){
		if(i!=l && ((s[i-1][p]!=base+c && s[i-1][p]!='?')||(s[i-1][p]=='?' && c==0)))  break;
		ret=ADD(ret,MUL(rec(l,i,p+1,0),rec(i,r,p,c+1),mod),mod);
	}
	return ret;
}

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

	rep(i,n){
		cin >> s[i];
		while(int(s[i].size())<20) s[i]+=base;
		//cout << s[i].size() << endl;
	}

	clr(memo,-1);
	cout << rec(0,n,0,0) << endl;
	return 0;
}

Measured memory_bytes: 35968
# 値とその出現回数でdictなりして値が大きいやつから採用すりゃいい
# 8 8 8 9 10 10 10 10 11 11など
# -> 失敗 5ケースほど
#    4つ以上あるときにもansをkで更新してしまっていたのがミスかな
# -> 失敗 2ケース....
# 意味不明
# あれか 既に4未満2以上の最大が埋まっているときに4以上のものがきたときの分岐

n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)
dict = {}
arr.each do |a|
  if dict.has_key?(a)
    dict[a]+=1
  else
    dict[a]=1
  end
end
dict = dict.sort.reverse
a, b = 0, 0
ans = 0
dict.each do |k, v|
  break if ans != 0
  if v>=4
    if a!=0
      b = k
    else
      a, b = k, k
    end
  elsif a == 0 && v>=2
    a = k
  elsif a != 0 && v>=2
    b = k
  end
  ans = a*b
end

puts ans

Measured memory_bytes: 22536
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    vector<int> p(5);
    rep(i,5) cin>>p[i];
    int ans;
    rep(i,5) if(p[i]==0) ans=i;
    cout<<ans+1<<endl;
}

Measured memory_bytes: 3544
#include<iostream>
#include<algorithm>
#include<iterator>
#include<vector>
#include<string>
#include<map>

using namespace std;


#define mod(cans) cans%10**9+7
#define cin_pl(x,y) for(int i=0;i<x;i++){cin>>y[i];}
#define pl_twin(x,y,z) for(int i=0;i<x;i++){cin>>y[i]>>z[i];}
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define st(s) size_t size = s.length()
#define prians(Answer) cout<<Answer<<"\n"
#define com_div(x,Co) for(int i=1;i<x+1;i++){if(x%i==0){Co++;}}
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int>> matrix;
typedef pair<int,int> pr;
typedef vector<pr> vpt;
typedef greater<int> gi;

int main()
{
    int n;
    cin>>n;
    int count=0;
    vi p(n),q(n);
    cin_pl(n,p);
    cin_pl(n,q);
    rep(i,n)
    {
        if(p[i]-q[i]>0)
        count+=p[i]-q[i];
    }
    prians(count);

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
/* Coding space */
bool dp1[5001][5001] = {};
bool dp2[5001][5001] = {};
int main(){
  int n,k; cin >> n >> k;
  vi in(n);
  rep(i,n) cin >> in[i];

  rep(i,n+1)  dp1[i][0] = 1,dp2[i][0] = 1;
  rep(i,n)rep(j,k){
    if(dp1[i][j]){
      dp1[i+1][j] = 1;
      if(j + in[i] <= k)
        dp1[i+1][j+in[i]] = 1;
    }
  }
  for(int i = n; i > 0; i--)rep(j,k){
    if(dp2[i][j]){
      dp2[i-1][j] = 1;
      if(j + in[i-1] <= k)
        dp2[i-1][j+in[i-1]] = 1;
    }
  }
  int ans = n;
  rep(i,n){
    [&](){
    set<int> table;
    //rep(j,k+1) cerr << i << " " << j << " " << dp2[i+1][j] << endl;
    rep(j,k+1) if(dp2[i+1][j]) table.insert(j);
    rep(j,k+1){
      if(dp1[i][j]){
        auto itr = table.lower_bound(k - (j + in[i]));
        if(itr != table.end() && *itr + j < k){
          //cerr << i << " " << j << endl;
          ans--;
          return;
        }
      }
    }
    }();
  }
  cout << ans << endl;
}

Measured memory_bytes: 49408
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int main(){
	int N;
	long long int K;
	cin >> N >> K;

	struct comp {
		int val;
		int num;

	    bool operator<(const comp& another) const {
	        return val < another.val;
	    }
	};

	vector<comp> c;

	FOR(i,0,N){
		comp cc;
		cin >> cc.val >> cc.num;
		c.push_back(cc);
	}
	sort(c.begin(),c.end());

	long long int css = 0;
	int ret = 0;
	for(comp co : c){
		css += co.num;
		ret = co.val;
		if (css >= K) break;
	}

	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 1400
#include<iostream>

using namespace std;

int size_a, A[2000];

bool check(int num, int elem) {
	if (elem == 0) return true;
	if (num >= size_a) return false;
	bool res = check(num + 1, elem) || check(num + 1, elem - A[num]);
	return res;
}

int main() {
	int rep, elem;
	cin >> size_a;
	for (int i = 0; i < size_a; ++i) {
		cin >> A[i];
	}
	cin >> rep;
	for (int i = 0; i < rep; ++i) {
		cin >> elem;
		if (check(0, elem)) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
from bisect import bisect_left
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for i in range(N):
  for j in range(i+1, N):
    index = bisect_left(L, L[i]+L[j])
    ans += max(index-j-1, 0)
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
#define tc int t;cin>>t;while(t--)
#define get cin>>
#define geta ll a[n];for (int i = 0; i < n; ++i){cin>>a[i];}
#define puta for (int i = 0; i < n; ++i){cout<<a[i];}
#define put cout<<
ll maxi=LLONG_MIN;
ll mini=LLONG_MAX;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
int n,k;
int a[101];
int dp[100001]={0};
int stone(int k)
{
	if(dp[k]){return dp[k];}
	for (int i = 0; i < n; ++i)
	{
		if (k>=a[i]&&stone(k-a[i])==2)
		{
				dp[k]=1;
				return dp[k];
		}
	}
	dp[k]=2;
	return dp[k];
}
int main() 
{
   fast();
   cin>>n>>k;
   for (int i = 0; i < n; ++i)
   {
   	cin>>a[i];
   }
   if (stone(k)==1)
   {
   	cout<<"First";
   }
   else
   {
   	cout<<"Second";
   }
   return 0;
}

Measured memory_bytes: 3712
A = int(input())
B = int(input())
C = int(input())
X = int(input())
num = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if 500 * a + 100 * b + 50 * c == X:
                num += 1
                break
print(num)


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

int main() {
  int a;
  int b;
  int c;
  int x;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> x;
  int counter = 0;
  for (int i=0; i <= a; ++i) {
    int A = i * 500;
    for (int j=0; j <= b; ++j) {
      int B = j * 100;
      for (int k=0; k <= c; ++k) {
        int C = k * 50;
        if (A + B + C == x) {
          ++counter;
        }
      }
    }
  }
  cout << counter << endl;
  return 0;
}


Measured memory_bytes: 256
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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 FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI 3.14159265358979323846264338327950L

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define int long long
#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vecotor<vector<int> >
#define VPII vector<pair<int,int> >

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val) {
	std::fill( (T*)array, (T*)(array + N), val );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言
int H, W, sh, sw, gh, gw;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};//BFS関連







//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main() {
	//入力の高速化用のコード
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	int K,sum=0;
	cin>>K;
	FOR(a,1,K)FOR(b,1,K)FOR(c,1,K){
		sum+=gcd(c,gcd(a,b));

	}
	cout<<sum<<endl;


	return 0;

}







Measured memory_bytes: 3548
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll a,b;
	scanf("%lld%lld",&a,&b);
	printf("%lld",(a+b)%24);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int N,K,num;
	int cnt=0;
	int aa;
	int ans=0;
	int like[40]={0};
	cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>num;
		for(int j=0;j<num;j++){
			cin>>aa;
			like[aa]++;
		}
	}
	for(int i=0;i<=K;i++){
		if(like[i]==N) cnt++;
	}
	cout<<cnt<<endl;
}


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

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string[] line = S.Split(' ');
            int A = int.Parse(line[0]);
            int B = int.Parse(line[1]);
            int ans = 0;

            if(A > B)
            {
                ans = ans + A;
                A--;
            }
            else
            {
                ans = ans + B;
                B--;
            }

            if (A > B)
            {
                ans = ans + A;
                A--;
            }
            else
            {
                ans = ans + B;
                B--;
            }

            Console.WriteLine(ans);


        }
    }
}

Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main(){
    int A,B;
    bool check = false;
    cin >> A >> B;

    for(int i = 1; i <= 3; i++){
        if((A*B*i) % 2 != 0) check = true;
    }

    if(check) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 888
#include<iostream>
//#include<iomanip>
#include<vector>
#include<algorithm>
#include<cmath>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,b)  for(int i=0;i<(int)(b);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
typedef long long ll;
typedef long double ld;

using namespace std;

int main(){
    cs;
    string s;
    cin>>s;
    rep(i,3) if(s[i]=='7') {cout<<"Yes";return 0;}
    cout<<"No";
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long n,t,k=0,y=100001;
    cin>>n>>t;
    f(i,1,n){
        long a=0,b=0;
        cin>>a>>b;
        if(b<=t){
            {k++;y=min(a,y);}
        }
    }
    if(k>0)
      cout<<y;
    else 
      cout<<"TLE";
}   
    
    
     

     
   





Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

char a[31][31];
int h, w, k;
char b[31][31];
void drop()
{
	for(int i = h - 1; i >= 0; i--)
	{
		for(int j = w - 1; j >= 0; j--)
		{
			if(b[i][j] == '$')
			{
				for(int k = i - 1; k >= 0; k--)
				{
					if(b[k][j] != '$')
					{
						for(int l = i; l - (i - k) >= 0; l--)
						{
							b[l][j] = b[l-(i-k)][j];
						}
						for(int l = i - k - 1; l >= 0; l--) b[l][j] = '$';
						break;
					}
				}
			}
		}
	}
}

ll clr()
{
	ll cnt = 0;
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < w - 2; j++)
		{
			if(b[i][j]==b[i][j+1]&&b[i][j+1]==b[i][j+2])
			{
				if(b[i][j]!='$')
				{
					cnt+=3*(b[i][j]-'0');
				}
				b[i][j]=b[i][j+1]=b[i][j+2]='$';
			}
		}
	}
	if(k==2)
	{
		for(int i = 0; i < h; i++)
		{
			for(int j = 0; j < w - 1; j++)
			{
				if(b[i][j]==b[i][j+1])
				{
					if(b[i][j]!='$')
					{
						cnt+=2*(b[i][j]-'0');
					}
					b[i][j]=b[i][j+1]='$';
				}
			}
		}
	}
	return cnt;
}

void out()
{
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < w; j++)
		{
			cout << b[i][j];
		}
		cout << '\n';
	}
	cout<<'\n';
}

ll play()
{
	//out();
	drop();
	//out();
	ll ans = 0;
	for(int i = 0; i < 30; i++)
	{
		ans += (1LL<<i)*clr();
		//if(i==0) out();
		drop();
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>h>>w>>k;
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < w; j++)
		{
			cin>>a[i][j];
		}
	}
	ll ans = 0;
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < w; j++)
		{
			for(int ix = 0; ix < h; ix++)
			{
				for(int jj = 0; jj < w; jj++)
				{
					b[ix][jj] = a[ix][jj];
				}
			}
			b[i][j] = '$';
			ans = max(ans, play());
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    double d, t, s;
    cin >> d >> t >> s;
    if (d / s <= t) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

const int maxn = 5005;
const long long MOD = 1000 * 1000 * 1000 + 7;
int dp[maxn][maxn];

int f(int i, int j) {
  if (i <= 0) {
    return j == 0;
  }

  if (j > i) {
    return 0;
  }

  if (dp[i][j] == -1) {
    long long ret = 0;
    ret += f(i - 1, j + 1);
    ret += f(i - 1, j + 1);
    ret += f(i - 1, max(j - 1, 0));
    dp[i][j] = ret % MOD;
  }
  return dp[i][j];
}

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

  memset(dp, -1, sizeof dp);
  
  int ans = f(n, s.size());
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 98304
n = int(raw_input())
for i in range(n):
    edge = map(int,raw_input().split(" "))
    e0 = edge[0] * edge[0]
    e1 = edge[1] * edge[1]
    e2 = edge[2] * edge[2]
    ret = "NO"
    if (edge[0] > edge[1]) and (edge[0] > edge[2]):
        if (e0 - e1 - e2) == 0:
            ret = "YES"
    if (edge[1] > edge[0]) and (edge[1] > edge[2]):
        if (e1 - e0 - e2) == 0:
            ret = "YES"
    if (edge[2] > edge[0]) and (edge[2] > edge[1]):
        if (e2 - e0 - e1) == 0:
            ret = "YES"
    print ret

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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

int main() {
	int n;
	cin >> n;
	int sum = 0;
	vector<int> s(n);
	rep(i, n) {
		cin >> s[i];
		sum += s[i];
	}
	if (sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	}
	sort(s.begin(), s.end());
	rep(i, n) {
		sum -= s[i];
		if (sum % 10 != 0) {
			cout << sum << endl;
			return 0;
		}
		sum += s[i];
	}
	cout << 0 << endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long r,g;
    scanf("%ld%ld", &r, &g);
    
    printf("%ld\n", r+(g-r)*2);



    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k <= a) cout << k << endl;
  else if (k <= a + b) cout << a << endl;
  else cout << a - (k-a-b) << endl;


  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
    string s;
    int k,c;
    cin>>s>>k;
    for(int i=0;k!=0&&i<s.size();i++){
        c=((s[i]=='a')?0:('z'-s[i]+1));
        if(c<=k)k-=c,s[i]='a';
    }
    if(k!=0)s[s.size()-1]=char(s[s.size()-1]+k%26);
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MAX_Q = 2 * 1e5 + 5;

int N,Q;
string S;
char t[MAX_Q], d[MAX_Q];


bool isOK1(int index)
{
    REP(i,Q)
    {
        if(t[i] == S[index])
        {
            if(d[i] == 'R') index++;
            else index--;
            if(index < 0) return true;
            if(index >= N) return false;
        }
    }
    return false;
}

bool isOK2(int index)
{
    REP(i,Q)
    {
        if(t[i] == S[index])
        {
            if(d[i] == 'R') index++;
            else index--;
            if(index < 0) return false;
            if(index >= N) return true;
        }
    }
    return false;
}


int binary_search1() {
    int ng = N; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = -1; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (abs(ng - ok) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK1(mid)) ok = mid;
        else ng = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return ok;
}

int binary_search2() {
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = N; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (abs(ng - ok) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK2(mid)) ok = mid;
        else ng = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return ok;
}





int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    cin >> N >> Q >> S;
    REP(i,Q)
    {
        cin >> t[i] >> d[i];
    }

    int ans1 = binary_search1();
    int ans2 = binary_search2();
    int ans = ans2 - ans1 - 1;

    cout << ans << endl;


}


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

struct P
{
    int x,y,z;

    bool operator<(const P &a)const{
              return z>a.z;
    }
};


vector<P> v[10];
//bitset<4001000> b;
int a,c,i,b,k,n,d,e,m;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[33];

int o[3301][333];
int j[11];
int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={-1,0,1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};


long long x,y,mod=1000000007;
long long z[222222];

P u[120];
stack<int> s;
//queue<int> q,q1,q2;
//set<int> s;
queue<int> q;

//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<long long,int> p;
//list<int> l;
//string r1,r;
char r[322][332];
//deque<int> de;
bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}


int main()
{
    scanf("%d",&a);
    for(int t=0;t<a;t++)
        scanf("%s",r[t]);
    for(int i=0;i<a;i++)
    {
        for(int t=0;t<a;t++)
            for(int w=0;w<a;w++)
            o[(t+i)%a][w]=r[t][w];
        for(int t=0;t<a;t++)
            for(int w=0;w<a;w++)
            if(o[t][w]!=o[w][t]) goto qwe;
        x+=a;
        qwe:;
    }
    printf("%lld",x);
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int n, m;

long long func(vector<long long> x[3], int f)
{
	vector<long long> _x[3];

	for (size_t i = 0; i < 3; i++)
	{
		copy(x[i].begin(), x[i].end(), back_inserter( _x[i]));

		if ((f >> i) & 1)
		{
			for (auto& d : _x[i])
			{
				d *= -1;
			}
		}
	}


	vector<long long> s;
	for (size_t i = 0; i < n; i++)
	{
		s.push_back(_x[0][i] + _x[1][i] + _x[2][i]);
	}

	sort(s.begin(), s.end());

	long long sum = 0;
	for (auto it = (s.end() - m); it != s.end(); it++)
	{
		sum += *it;
	}

	return sum;
}

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

	vector<long long> x[3];

	for (size_t i = 0; i < n; i++)
	{
		for (size_t j = 0; j < 3; j++)
		{
			long long dat;
			cin >> dat;
			x[j].push_back(dat);
		}
	}


	vector<long long> s;

	for (size_t i = 0; i < 8; i++)
	{
		s.push_back(abs(func(x, i)));
	}
	sort(s.begin(), s.end());

	cout << s.back() << endl;

	return 0;
}


Measured memory_bytes: 256
N, K, C = gets.split.map{|i|i.to_i}
S = gets.chomp
#warn "%d %d" % [K, C]
#warn S
left = Array.new(K)
right = Array.new(K)
l = 0
r = N - 1
K.times{|k|
	l += 1 while S[l] == "x"
	r -= 1 while S[r] == "x"
	left[k] = l
	right[K - k - 1] = r
	l += C + 1
	r -= C + 1
}
#warn left.inspect
#warn right.inspect
result = []
K.times{|i|
	if left[i] == right[i]
		result << left[i] + 1
	end
}
puts result


Measured memory_bytes: 8184
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;
typedef long long ll;

int vs[110];

int main(void) {
  int n;
  cin >> n;
  int sum = 0;
  REP(i, n) {
    cin >> vs[i];
    sum += vs[i];
  }
  sort(vs, vs + n);
  puts(vs[n-1] < sum - vs[n-1] ? "Yes" : "No");
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define MOD 1000000007

using namespace std;

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

    long long all = 1;
    long long noZero = 1;
    long long noNine = 1;
    long long noZeroAndNine = 1;

    for (int i = 0; i < n; i++) {
        all = all * 10 % MOD;
        noZero = noZero * 9 % MOD;
        noNine = noNine * 9 % MOD;
        noZeroAndNine = noZeroAndNine * 8 % MOD;
    }

    long long result = all - ((noZero - noZeroAndNine) + (noNine - noZeroAndNine) + noZeroAndNine);
    result %= MOD;
  	result = (result + MOD) % MOD;

    cout << result << endl;

    return 0;
}

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

int A, B, C, X, Y;

int main(){
    cin >> A >> B >> C >> X >> Y;
    int AB = 2 * C;
    long long int ans = LLONG_MAX;
    for (int i = 0; i < 200001; i++){
        long long int price = A * max(X - i, 0) + B * max(Y - i, 0) + AB * i;
        //cout << price << endl;
        ans = min(price, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;


vector<int> divisor(int n){

  vector<int>res;
  for(int i=1; i*i<=n; i++){
    if(n%i==0){
      res.push_back(i);
      if(i!=n/i)res.push_back(n/i);
    }
  }
  return res;
}

int main(void){

  int p,l,n,m;
  vector<int>L,N,M;

  cin >> p;

  if(p==2){
  
    cin >> n >> m;

    N.clear();
    M.clear();

    N=divisor(n);
    M=divisor(m);    

    sort(N.begin(),N.end());
    sort(M.begin(),M.end());

    for(int i=0;i<N.size();i++)
      if(binary_search(M.begin(),M.end(),N[i]))cout << N[i] << endl;
    
  }
  else if(p==3){
    
    cin >> l >> n >> m;

    L.clear();
    N.clear();
    M.clear();

    L=divisor(l);
    N=divisor(n);
    M=divisor(m);    

    sort(L.begin(),L.end());
    sort(N.begin(),N.end());
    sort(M.begin(),M.end());


    for(int i=0;i<N.size();i++)
      if(binary_search(M.begin(),M.end(),N[i]) &&
	 binary_search(L.begin(),L.end(),N[i]))cout << N[i] << endl;
  }  
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

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

  vector<int> a(n);
  vector<int> b(n);

  for (int i = 0; i < n; ++i) {
    int ai, bi;
    cin >> ai >> bi;
    a[i] = ai;
    b[i] = bi;
  }

  int inf = 1e9;
  vector<int> dp(h + 1, inf);
  dp[0] = 0;

  for (int hi = 0; hi <= h; ++hi) {
    for (int i = 0; i < n; ++i) {
      int value = a[i];
      int cost = b[i];
      if (hi - value >= 0) {
        dp[hi] = min(dp[hi], dp[hi - value] + cost);
      } else {
        dp[hi] = min(dp[hi], cost);
      }
    }
  }

  cout << dp[h] << endl;
  // for (int el : dp) {
  //   cout << el << endl;
  // }
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

void solve(){
    int n;cin >> n;
    vector<int>a(2e5,0);
        for(int x = 1;x<=sqrt(n);x++){
            for(int y = 1;y<=sqrt(n);y++)
            for(int z = 1;z<=sqrt(n);z++)
            a[x*x+y*y+z*z+x*y+y*z+x*z]++;
        }
        for(int i = 1;i<=n;i++){
            cout << a[i]<<endl;
        }
    }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3976
import fractions
A,B,C,D = map(int,input().split())
num_gcd = C*D//fractions.gcd(C,D)
ans_B = 0 - B//C - B//D + B//num_gcd
ans_A = 0 - (A-1)//C - (A-1)//D + (A-1)//num_gcd
ans = B - A + 1 + ans_B - ans_A
print(ans)

Measured memory_bytes: 5048
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  string s,p;
  cin >> s >> p;
  s += s;
  if(s.find(p)!=string::npos) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2e5+10;
int a[maxn];
int main(){
	int n=read();
	REP(i,1,n) a[i]=read();
	if(a[1]!=0){
		printf("-1\n");
		return 0;
	}
	REP(i,2,n) if(a[i]>a[i-1]+1){
		printf("-1\n");
		return 0;
	}
	ll ans=a[n];
	DREP(i,n-1,2) if(a[i]!=a[i+1]-1) ans+=a[i];
	printf("%lld\n",ans);
	return 0;
}


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


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	int ans = 0;
	rep(i, 2) {
		if (a > b) {
			ans += a;
			a -= 1;
		}
		else {
			ans += b;
			b -= 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>

#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
#include <complex>

#define REP(i,a,b) for(int i=a; i<b; i++)
#define rep(i,n) REP(i,0,n)
#define FOR(i,c) for(typeof((c).begin())i=(c).begin();i!=(c).end(); ++i)

#define EXIST(e,s)((s).find(e)!=(s).end())
#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))

#define ll long long

using namespace std;

int w, h;
int num;
int field[50][50];

int d[8][2] = {{-1,-1},{0,-1},{1,-1},{-1,0},{1,0},{-1,1},{0,1},{1,1}};

void search(int x, int y){
  if(field[y][x] == 1){
    field[y][x] = 0;
    for(int i=0; i<8; i++){
      if(0<=x+d[i][0] && x+d[i][0]<w && 0<=y+d[i][1] && y+d[i][1]<h){
	search(x+d[i][0], y+d[i][1]);
      }
    }
  }
}

int main(void){
  while(cin >> w >> h, w || h){
    num = 0;
    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
	cin >> field[i][j];
      }
    }

    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
	if(field[i][j] == 1){
	  num++;
	  search(j, i);
	}
      }
    }
    cout << num << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1224
//
// Created by MengHaitao on 2019/11/27 0027.
//
#include <iostream>
#include <string>
#include <queue>
using namespace std;
#define pr pair<string,int>
queue<pr> q;
int n, times, sum;
void solve() {
    while (!q.empty()) {
        pr value = q.front();
        q.pop();
        if (times - value.second >= 0) {
            sum =sum+value.second;
            cout << value.first<<" "<<sum << endl;
        } else {
            sum =sum+times;
            value.second-=times;
            q.push(value);
        }
    }
}

int main() {
    pr t;
    cin >> n >> times;
    while (n--) {
        cin >>t.first>> t.second;
        q.push(t);
    }
    solve();
}



Measured memory_bytes: 6304
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    set<int> s;
    int t;
    rep(i,3) {
        cin >> t;
        s.insert(t);
    }
    if (s.size() ==2 ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n,k,s;

int ans[125252];

int main(){
    scanf("%d%d%d",&n,&k,&s);
    REP(i,k)ans[i] = s;
    if(s != 1'000'000'000){
        FOR(i,k,n)ans[i] = s+1;
    }else{
        FOR(i,k,n)ans[i] = 1;
    }
    REP(i,n)printf("%d%c",ans[i]," \n"[i==n-1]);
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using namespace std;
using lli = long long;
using pii = pair<int,int>;

char str[200100];
int cnt[30],cc[30],n;

struct seg_tr{
    const static int MAX=1<<18;
    int tr[MAX];

    void upd(int cur) {
        cur++;
       while(cur<=n) tr[cur]++,cur+=cur&-cur;
    }
    int sum(int cur) {
        int ret=0;
        while(cur) {
            ret += tr[cur], cur-=cur&-cur;
        }
        return ret;
    }
    int get(int l,int r) {
        return sum(r+1)-sum(l);
    }
}sg;

int main() {
    scanf("%s",str);
    n=strlen(str);
    for(int i=0;i<n;i++) cnt[str[i]-'a']++;
    
    int of=0;
    for(int i=0;i<26;i++) {
        if(cnt[i]%2==1) {
            if(of) {
                puts("-1");
                return 0;
            }
            of=1;
        }
    }
    
    vector<char> fv,ev;
    int c=0;
    lli ans=0;
    for(int i=0;i<n;i++) {
        int idx=str[i]-'a';
        if(cc[idx] < cnt[idx]/2) {
            fv.push_back(str[i]);
            ans += sz(ev)+c;
        } else if(cc[idx] >= (cnt[idx]+1)/2) {
            ev.push_back(str[i]);
        } else ans += sz(ev),c=1;
        cc[idx]++;
    }
    reverse(ev.begin(),ev.end());

    queue<int> pos[26];
    for(int i=0;i<sz(ev);i++) pos[ev[i]-'a'].push(i);
    
    vector<pii> query;
    for(int i=0;i<sz(fv);i++) {
        int idx=fv[i]-'a',j=pos[idx].front();
        pos[idx].pop();
        ans += sg.get(j+1,n);
        sg.upd(j);
    }
    printf("%lld\n",ans);
    
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265359
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)

int main() {
    ll n,a[200010],ans=0,sum[200010];
    cin >> n;
    rep(i,n) {
        cin >> a[i];
        if(i==0) sum[i]=a[i];
        else sum[i]=sum[i-1]+a[i];
    }
    for(int i=0;i<n-1;i++){
        ll hoge = sum[n-1] - sum[i];
        hoge %= MOD;
        hoge *= a[i];
        hoge %= MOD;
        ans += hoge;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
  int N; cin >> N;
  vector<double> x(N);
  vector<string> u(N);
  for (int i = 0; i < N; ++i) {
    cin >> x[i] >> u[i];
  }

  double sum = 0;
  for (int i = 0; i < N; ++i) {
    if (u[i] == "JPY") {
      sum += x[i];
    } else {
      sum += x[i] * 380000;
    }
  }

  cout << sum << endl;
}

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

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

typedef long long unsigned int ll;

ll N, M;


void solve(){
  int field[N][M];
  rep(i, N){
    rep(j, M){
      field[i][j] = 1;
    }
  }

  rep(i, N){
    rep(j, M){
      for(int dx = -1; dx <= 1; dx++){
        for(int dy = -1; dy <= 1; dy++){
          int nx = dx + i, ny = dy + j;
          if(0<=nx && nx<N && 0<=ny && ny<M){
            if(field[nx][ny] == 1){
              field[nx][ny] = 0;
            }else{
              field[nx][ny] = 1;
            }
          }
        }
      }
    }
  }
  rep(k, N){
    rep(m, M){
      cout << field[k][m];
    }
    cout << endl;
  }
  cout << endl;
  int cnt = 0;
  rep(i, N){
    rep(j, M){
      if(field[i][j] == 0) cnt++;
    }
  }
  cout << cnt << endl;
}

void solve2(){
  if(M == 1 && N == 1){
    cout << 1 << endl;
  }else if(N == 1){
    cout << M - 2 << endl;
  }else if(M == 1){
    cout << N -2 << endl;
  }else{
    cout << (M-2)*(N-2) << endl;
  }
}

int main(){
  cin >> N >> M;
  solve2();
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){

  int num[3];
  int i=0,j=0;
  int tmp=0;

  for(i=0; i<3; i++){
    scanf("%d",&num[i]);
  }

  for(i=0; i<3; i++){
    for(j=i+1; j<3; j++){
      if(num[i] > num[j]){
        tmp = num[i];
        num[i] = num[j];
        num[j] = tmp;
      }
    }
  }


  printf("%d %d %d\n",num[0],num[1],num[2]);


  return 0;
}



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

l = []
for i in range(n):
    l.append(input())

if len(set(l)) != n :
    print("No")
    exit()

for i in range(n-1) :
    if l[i][-1] != l[i+1][0]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 3060
s = input()
t = input()
ss = len(s)
l = len(t)
ans = []
tl = list(t)
for i in range(len(s) - l + 1):
    tl2 = list(s[i:i + l])
    f=1
    for j in range(l):
        if tl[j] != tl2[j] and tl2[j] != "?":
            f=0
            break
    if f==1:
        s1=s[:i].replace("?","a")
        s2=s[i+l:].replace("?","a")
        ans.append(s1 + t + s2)
if len(ans)==0:
    print("UNRESTORABLE")
else:
    ans.sort()
    print(ans[0])


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll power(ll a,ll b){
if(b==0)
    return 1;
if(b==1)
    return a;
ll t=power(a,b/2);
if(b%2==0)
    return t*t;
return a*t*t;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("ouput.txt","w",stdout);
    #endif // ONLINE_JUDGE
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    */

ll t;
cin>>t;
if(t>=30)
    cout<<"Yes\n";
else
    cout<<"No\n";
    return 0;
}


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

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

    bool good = true;
    for (int i=0; i<S.size()-1; i++) {
        if (S.at(i) == S.at(i+1)) {
            good = false;
            break;
        }
    }

    if (good) {
        cout << "Good" << endl;
    } else {
        cout << "Bad" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
public class Main {
    public static void main(String args[]) {
        for(int i = 1; i <= 9; i++) {
            for(int j = 1; j <= 9; j++) {
                // ?¨?????????????????????????
                System.out.println(""+i+'x'+j+'='+(i*j));
            }
        }
    }
}

Measured memory_bytes: 24512