akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
  int H,W;
  cin>>H>>W;
  vector<int> Hs(H,0),Ws(W,0);
  vector<vector<char>> Mat(H, vector<char>(W, ' '));
  for (int i = 0; i < H; i++) {
    bool skip = true;
    for (int j = 0; j < W; j++) {
      cin>>Mat[i][j];
      if (Mat[i][j] == '#') skip = false;
    }
    if (skip) Hs[i] = 1;
  }
  for (int i = 0; i < W; i++) {
    bool skip = true;
    for (int j = 0; j < H; j++) {
      if (Mat[j][i] == '#') skip = false;
    }
    if (skip) {
      Ws[i] = 1;
    }
  }
  for (int i = 0; i < H; i++) {
    bool ok = false;
    for (int j = 0; j < W; j++) {
      if (Hs[i] == 0 && Ws[j] == 0) ok = true, cout<<Mat[i][j];
    }
    if(ok) cout<<"\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
  int a=0;
  scanf("%d",&a);
  for(int i=1;i<=9;i++){
	  if(a%i==0){
	  if((a/i)>=1){
		  if((a/i)<=9){
			  printf("Yes");
			  return 0;
		  }
	  }
	  }
    }
	printf("No");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<climits>
#define ll long long int
#define mod 1000000007
#define pi acos(-1)
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int a ;
  string str1, str2;
  cin>>a>>str1>>str2;
  for(int i=0;i<a;i++)
    cout<<str1[i]<<str2[i];
  
  return 0;
}

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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  // freopen("in.txt", "r", stdin);
  int x;
  cin >> x;
  if(x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3648
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def score(tt):
    ans=0
    for i,t in enumerate(tt):
        t-=1
        ans += ss[i][t]
        p = i - last[t]
        ans -= p * (p + 1) // 2 * cc[t]
        last[t] = i + 1
    for t in range(26):
        p = d - last[t]
        ans -= p * (p + 1) // 2 * cc[t]
    return ans

inf=10**16
d = II()
cc = LI()
ss = LLI(d)
ans = 0
last = [0] * 26
tt=list(range(1,27))*(d//26+1)
tt=tt[:d]
for _ in range(50):
    for i in range(d):
        mx=-inf
        best=0
        for j in range(1,27):
            tt[i]=j
            cur=score(tt)
            if cur>mx:
                mx=cur
                best=j
        tt[i]=best
#print(score(tt))
print(*tt,sep="\n")


Measured memory_bytes: 69208
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repb(i, n) for (int i = (int)n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define repsb(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[])
{
    int s;
    cin >> s;
    int tmp = s / 100;
    //cout << s - tmp * 100; //1.2

    if (tmp < 13 && s - tmp * 100 < 13 && tmp != 0 && s - tmp * 100 != 0)
    {
        cout << "AMBIGUOUS";
        return 0;
    }
    if (tmp < 13 && tmp != 0)
    {
        cout << "MMYY";
        return 0;
    }

    if (s - tmp * 100 < 13 && s - tmp * 100 != 0)
    {
        cout << "YYMM";
        return 0;
    }
    cout << "NA";
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int num(int n) {
  return ((n+9)/10)*10;
}

int main() {
  vector<int> a(5), dif(5);
  int sum = 0;
  rep(i, 5) {
    cin >> a[i];
  }
  rep(i, 5) {
    dif[i] = a[i] % 10;
    if (dif[i] == 0) dif[i] = 10;
    sum += num(a[i]);
  }
  sort(all(dif));
  sum = sum - 10 + dif[0];
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int[] A = GetInts(N);
		WriteLine(A.Distinct().Count() == N ? "YES" : "NO");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 39376
#include <iostream>
#include <vector>

using namespace std;

int main() {

    int n;

    cin >> n;

    while(n) {
        if(n % 10 == 9) {
            cout << "Yes" << endl;
            return 0;
        }
        n /= 10;
    }

    cout << "No" << endl;

}

Measured memory_bytes: 256
lun_luns = [1, 2, 3, 4, 5, 6, 7, 8, 9]
k = int(input())
index = 0
while True:
	if len(lun_luns) >= k:
		break
	num = lun_luns[index]
	mod = num % 10
	n = num * 10
	if mod == 9:
		lun_luns.extend([n+mod-1, n+mod])
	elif mod == 0:
		lun_luns.extend([n, n+1])
	else:
		lun_luns.extend([n+mod-1, n+mod, n+mod+1])
	index += 1
print(lun_luns[k-1])

Measured memory_bytes: 45168
#include <stdio.h>
int main(void){
    int N;
    scanf("%d", &N);
    int n = 0;
    int orig = N;
    while (N > 0){
        n += N%10;
        N /= 10;
    }
    printf("%s\n", (orig%n == 0)? "Yes": "No");
    return 0; 
}

Measured memory_bytes: 128
#include<stdio.h>

#define M 100

int main(){
  int i,j;
  int n,u,k,v;
  int T[M][M];

  scanf("%d",&n);

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      T[i][j] = 0;
    }
  }

  for(i=0; i<n; i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0; j<k; j++){
      scanf("%d",&v);
      v--;
      T[u][v] = 1;
    }
  }

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      if(j == n-1) printf("%d",T[i][j]);
      else printf("%d ",T[i][j]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2108
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

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

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

    int res = 0;
    vector<bool> b(a[n - 1] + 1, true);
    for (int i = 0; i < n; i++) {
        if (b[a[i]]) {
            if (i == n - 1 || a[i] != a[i + 1]) {
                res++;
            }

            for (int j = a[i]; j <= a[n - 1]; j += a[i]) {
                b[j] = false;
            }
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 4060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#define rep(i,l,r) for(i=l;i<r;i++)
#define repb(i,r,l) for(i=r;i>l;i--)
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
const int mod=1000000007;
using namespace std;
bool sortlr(pll &a,pll &b){
    if(a.first!=b.first){
        return a.first<b.first;
    }
    else{
        return a.second<b.second;
    }
}

int main(){
    ll n;
    cin>>n;
    ll x[n],l[n];
    ll i;
    vector<pll> lr;
    rep(i,0,n){
        cin>>x[i]>>l[i];
        lr.pb(mp(x[i]-l[i]+1,x[i]+l[i]));
    }
    sort(lr.begin(),lr.end(),sortlr);
    ll ans=0;
    ll rightindex=lr[0].second;
    rep(i,1,n){
        
            if(lr[i].first<=rightindex){
                if(lr[i].second<=rightindex){
                    ans++;
                    rightindex=lr[i].second;
                }
                else{
                    ans++;
                }
            }
            else{
                rightindex=lr[i].second;
            }
        
    }
    cout<<n-ans;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n,x; cin >> n>>x;
  int d =0;
  int ans =1;
  rep(i,n) {
    int l; cin >> l;
    d << 1; d+=l;
    if (d>x) break;
    ans ++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#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;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
#define debug(x) cout<<#x<<' '<<x<<endl
#define read(x)  freopen("input.txt","r",stdin);
#define iter(x)  x.begin(),x.end()
#define ll long long
#define ull unsigned ll
#define endl '\n'
#define inf INT_MAX
#define mod 1000000007
vector<vector<pair<int,int> > >parent;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
pair<int,int>start,finish;
int h,w,k;
vector<vector<char> >grid;
bool valid(pair<int,int>p)
{
    return p.first<h and p.first>-1 and p.second<w and p.second>-1;
}
void bfs()
{

    queue<pair<int,int> >q;
    q.push(start);
    int dist[h][w];
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            dist[i][j]=inf ;
    dist[start.first][start.second]=0;
    while(!q.empty())
    {
        pair<int,int> p=q.front();
        q.pop();

        for(int i=0;i<4;i++)
            for(int jj=1;jj<=k;jj++)
        {
            pair<int,int>j={p.first+dx[i]*jj,p.second+dy[i]*jj};

            if(!valid(j) or grid[j.first][j.second]!='.')
            {

                break;
            }
            if(1+dist[p.first][p.second]<dist[j.first][j.second])
            {
                dist[j.first][j.second]=1+dist[p.first][p.second];
                q.push(j);

            }
            else if(1+dist[p.first][p.second]>dist[j.first][j.second])
            {

                break;

            }

        }
    }


    if(dist[finish.first][finish.second]!=inf)
    {
        cout<<dist[finish.first][finish.second]<<endl;

    }
    else
        cout<<-1<<endl;

}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>h>>w>>k;
    parent.assign(h,vector<pair<int,int> >(w));
    grid.assign(h,vector<char >(w));
    cin>>start.first>>start.second>>finish.first>>finish.second;
     start.first--,start.second--,finish.first--,finish.second--;
    for(auto &c:grid)
        for(auto &x:c)
            cin>>x;

    bfs();


}


Measured memory_bytes: 18712
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    s=input()
    c=Counter(s)
    cr=c['R']
    cw=N-cr
    if cr==N:
        print(0)
        return
    cnt=0
    for i in range(cr):
        if s[i]=="W":
            cnt+=1
    print(cnt)




if __name__ == "__main__":
    main()

Measured memory_bytes: 73392
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int N, u, v;
	cin >> N;
	vector<vector<pair<int, long>>> a(N);
	for (int i = 1; i < N; i++) {
		long w;
		cin >> u >> v >> w;
		a[u - 1].emplace_back(v - 1, w);
		a[v - 1].emplace_back(u - 1, w);
	}
	priority_queue<pair<long, int>, vector<pair<long, int>>, greater<pair<long, int>>> b;
	b.emplace(0, 0);
	vector<bool> c(N);
	vector<long> d(N, LONG_MAX);
	d[0] = 0;
	while (!b.empty()) {
		pair<long, int> e = b.top();
		b.pop();
		c[e.second] = true;
		for (pair<int, long>& i : a[e.second]) {
			if (c[i.first]) continue;
			if (d[e.second] + i.second < d[i.first]) {
				d[i.first] = d[e.second] + i.second;
				b.emplace(d[i.first], i.first);
			}
		}
	}
	for (long& i : d) cout << i % 2 << endl;
}

Measured memory_bytes: 8704
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Wed Jan  9 20:55:17 2019
//
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var N int
	fmt.Scan(&N)
	n := strconv.Itoa(N)
	for i := range n {
		if n[i] != n[len(n)-1-i] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
<?php
$stack=[];
$top=0;
$data=explode(' ',trim(fgets(STDIN)));
foreach($data as $d){
  if($d=='+') $stack[$top-1]+=$stack[$top--];
  elseif($d=='-') $stack[$top-1]-=$stack[$top--];
  elseif($d=='*') $stack[$top-1]*=$stack[$top--];
  else $stack[++$top]=(int)$d;
}
print $stack[$top];
?>

Measured memory_bytes: 15500
a,b = map(int,input().split(" "))
ar = []
br = ["#" for i in range(b+2)]
ar.append(br)
for j in range(a):
    cr = list(input())
    cr.insert(0,"#")
    cr.append("#")
    ar.append(cr)
ar.append(br)
for r in ar:
    print("".join(r))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;


template <typename T> T gcd(T a, T b) {if(b == 0) return a;return gcd(b,a%b);}
template <typename T> T extgcd(T a, T b, T& x, T& y){
    T d = a;
    if(b != 0){d = extgcd(b,a%b,y,x); y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> T modpow(T x, T n, T m) {
    if(n==0) return 1;
    T resp = modpow(x*x%m,n/2,mod);
    if(n&1) resp = resp*x%m;
    return resp;
}
template <typename T> T modinverse(T a, T m) {
    T x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
struct combination {
    ll M = mod;
    vector<ll> fact;vector<ll> ifact;
    combination(ll n):fact(n+1),ifact(n+1){
        fact[0]=1;ifact[0]=1;
        for (ll i = 0; i<n; i++) {fact[i+1] = fact[i]*(i+1) % M;ifact[i+1] = ifact[i]*modpow(i+1, M-2, M) % M;}
    }
    ll com(ll a, ll b){
        if(a == 0 && b == 0)return 1;if(a < b || a < 0)return 0;
        ll tmp = ifact[a-b]* ifact[b] % M;
        return tmp * fact[a] % M;
    }
};



int main()
{

    int N;
    cin >> N;
    vl x(N);
    in(N,x);
    combination C((ll)N);
    ll ans = 0;
    ll cc = C.fact[N-1];
    
    reps(i,1,N){
        ans += (x[i]-x[i-1])*cc%mod;
        ans %= mod;
        cc += C.fact[N-1]*modinverse((ll)(i+1),mod)%mod;
    }
    out(ans%mod);


    return 0;
}


Measured memory_bytes: 2560
import sys


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


def input_ints():
    return list(map(int, input().split()))


def main():
    f = input_ints()
    print(f[0] * f[1])


main()


Measured memory_bytes: 9132
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int32_t main()
{
	FIO;
	string s, t; cin >> s >> t;

	int ln = t.length() - 1;

	if (s == t.substr(0, ln))
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 3620
mod = 10**9+7
MAX = (10**6)*2+1 #nは10**5までを想定
fact = [1]*(MAX+1)
for i in range(1, MAX+1):
    fact[i] = (fact[i-1]*i)%mod
inv = [1]*(MAX+1)
for i in range(2, MAX+1):
    inv[i] = inv[mod%i]*(mod-mod//i)%mod
fact_inv = [1] * (MAX + 1)
for i in range(1, MAX + 1):
    fact_inv[i] = fact_inv[i-1]*inv[i]%mod
def comb(n, r):
    if n < r:
        return 0
    return fact[n]*fact_inv[n-r]*fact_inv[r] % mod
ans = 0
r1,c1,r2,c2 = map(int,input().split())
for i in range(r1+1,r2+2):
    ans += comb(i+c2,c2)-comb(i+c1-1,c1-1)
    ans %= mod
print(ans)


Measured memory_bytes: 87900
#include<stdio.h>
 
int main(){
    int a,b,c,i=1;
    while(scanf("%d %d",&a,&b)!=EOF){
         c=a+b;
        while(c>=10){
            c=c/10;
            i++;
        }   
        printf("%d\n",i);
        i=1;
    }
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

static LL P = 1000000007;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long N;
	vector<long long> A;

	cin >> N;
	for(int i = 0; i < N; i++){
		long long v;
		cin >> v;
		A.push_back(v);
	}
	sort(A.begin(), A.end());

	long long ans = 0;
	if(N == 1){
		if(A[0] == 0){
			ans = 1;
		}
		else{
			ans = 0;
		}
		printf("%lld\n", ans);
		return 0;
	}

	if((N % 2 == 1)){
		// A は、0, 2, 2, 4, 4, ...のはず
		int match = 1;
		if(A[0] != 0){
			match = 0;
		}
		for(int i = 1; i < N; i++){
			if( (i % 2) == 0 && A[i] != i){
				match = 0;
				break;
			}
			if( (i % 2) == 1 && A[i] != i + 1){
				match = 0;
				break;
			}
		}
		if(match == 1){
			ans = 1;
			// 2**((N-1)/2)
			for(int j = 1; j <= (N - 1) / 2; j++){
				ans = ans * 2;
				ans = ans % P;
			}
			ans = ans % P;
			if(ans < 0) ans += P;
		}
		else{
			ans = 0;
		}
	}
	else if((N % 2) == 0){
		// A は、1, 1, 3, 3, 5, 5, ...のはず
		int match = 1;
		for(int i = 0; i < N; i += 2){
			if(A[i] != (i + 1)){
				match = 0;
				break;
			}
		}
		for(int i = 1; i < N; i += 2){
			if(A[i] != i){
				match = 0;
				break;
			}
		}
		if(match == 1){
			ans = 1;
			for(int j=1; j<=N/2; j++){
				ans = ans * 2;
				ans = ans % P;
			}
			ans = ans % P;
			if(ans < 0) ans += P;
		}
		else{
			ans = 0 ;
		}	
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1400
/*
      author : nishi5451
      created: 11.08.2020 22:20:27
*/

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


int main(){
    string s;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy" << endl;
    else if(s=="Cloudy") cout << "Rainy" << endl;
    else if(s=="Rainy") cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	bool p=false;
	for(int i=0;i<n;i++)
	{
		int h;
		cin>>h;
		if(h%2==0)
		{
			if(h%3!=0&&h%5!=0)
			p=true;
		}
	}
	if(p)
	cout<<"DENIED";
	else
	cout<<"APPROVED";
} 

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

void print(int A[], int N)
{
	int i;
	for (i = 0; i < N - 1; i++) cout << A[i] << " ";
	cout << A[i];
	cout << endl;
}



int selectionSort(int A[], int N)
{
	int cnt = 0;
	
	// i is sorted
	for (int i = 0; i < N; i++)
	{
		int minj = i;
		for (int j = i; j < N; j++)
		{
			if (A[j] < A[minj]) minj = j;
		}
		swap(A[i], A[minj]);
		if(i != minj) cnt++;
	}

	return cnt;
}



int main()
{
	int N, A[100];
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];

	int cnt = selectionSort(A, N);

	print(A, N);
	cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int i;
	string s;
	cin >> s;
	sort(s.begin(),s.end());
	for(i = 1;i < s.size();i++){
		if(s[i] == s[i-1]){
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
	return 0;
}


Measured memory_bytes: 256
n, y = map(int, input().split())
found = False
for i in range(n+1):
  for j in range(n+1-i):
    if i + j+ (n-i-j) == n and 10000*i+5000*j+1000*(n-i-j) == y:
        print(i, j, n-i-j)
        found = True
        break
  else:
    continue
  break 
if not found:
  print("-1 -1 -1")

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

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

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
#include <ctype.h>
using namespace std;
int n,p,s[100],q;
bool sw=false;
int main(){
	while(cin>>n>>p){
		if(n==0){break;}
		for(int i=0;i<p;i++){
		cin>>s[i];}
		for(int ii=0;ii<n;ii++){
		for(int iii=0;iii<p;iii++){
		cin>>q;s[iii]-=q;}}
		for(int a=0;a<p;a++){
			if(s[a]<0){sw=true;cout<<"No"<<endl;a=1000;}}
		if(sw==false){cout<<"Yes"<<endl;}
	sw=false;}
    return 0;}


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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    ll sum = 0;
    for(int i = n - 1; i >= 0; i--){
        a[i] += sum;
        sum += (b[i] - a[i] % b[i]) % b[i]; 
    }
    cout << sum << endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

const int N = 1e5 + 5;

int a[N];
int n;
long long dp[N][2];


int main()
{
        cin >> n;
        for (int i=1; i<=n; i++) cin >> a[i];
        dp[0][0] = 0;
        dp[0][1] = -1e9;
        for (int i=1; i<=n; i++)
        {
                dp[i][0] = max(dp[i-1][0] + a[i], dp[i-1][1] - a[i]);
                dp[i][1] = max(dp[i-1][0] - a[i], dp[i-1][1] + a[i]);
        }
        cout << dp[n][0];
        return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>
 
#define f first
#define s second
#define mp make_pair
 
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)
 
using namespace std;
 
typedef unsigned int uint;
typedef long long ll;
 
const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};
 
int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}
 
int main(){
  int n;
  while(scanf("%d ",&n), n){
    char m[128],a,b;
    REP(i,128) m[i] = i;
    REP(i,n){
      scanf("%c %c ",&a,&b);
      m[a] = b;
    }
    scanf("%d ",&n);
    REP(i,n){
      scanf("%c ",&a);
      putchar(m[a]);
    }
    puts("");
  }
  return 0;
}

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

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

const ll MOD = 1e9+7;

int dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
int dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

template<typename T>
void chmax(T &a, T b){
	a = max(a, b);
}

template<typename T>
void chmin(T &a, T b){
	a = min(a, b);
}

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

class RMQ{
	int n;
	vector<int> dat;
public:
	RMQ(int n_){
		n = 1;
		while(n < n_) n *= 2;
		REP(i, n*2-1){
			dat.push_back(INF);
		}
	}

	void update(int x, int i){
		i += n-1;
		dat[i] = x;
		while(i > 0){
			i = (i-1)/2;
			dat[i] = min(dat[i*2+1], dat[i*2+2]);
		}
	}

	int query(int a, int b, int l, int r, int x){
		if(a <= l && r <= b) return dat[x];
		if(r <= a || b <= l) return INF;

		int res = INF;
		res = min(query(a, b, l, (l+r)/2, x*2+1), query(a, b, (l+r)/2, r, x*2+2));
		return res;
	}
	int query(int a, int b){
		return query(a, b, 0, n, 0);
	}
};

const ll mod = 1e9+7;

int N, K;
vector<ll> a;
bool dp[5050] = {};

bool ok(ll in){
	if(in >= N) return true;
	memset(dp, 0, sizeof(dp));
	dp[0] = true;
	REP(i, N){
		if(i == in) continue;
		for(int j = K+1;j >= a[i];j--){
			if(dp[j-a[i]]) dp[j] = true;
		}
	}
	FOR(i, max(0, (int)K-(int)a[in]), K){
		if(dp[i]){
			return true;
		}
	}
	return false;
}

int main(void){
	int n;
	cin >> n;
	int nc[26];
	fill(nc, nc+26, INF);
	REP(i, n){
		string s;
		cin >> s;
		int tmp[26] = {};
		REP(j, s.size()){
			tmp[s[j]-'a']++;
		}
		REP(j, 26){
			nc[j] = min(nc[j], tmp[j]);
		}
	}
	REP(i, 26){
		REP(j, nc[i]){
			cout << (char)('a'+i);
		}
	}
	cout << endl;
}


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

int n;
int a[100001];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];

	sort(a, a + n);
	int M = (a[n - 1] + 1) / 2;
	int l = a[0], r = a[n - 1];
	for (int i = 0; i < n - 1; i++) {
		if (a[i] <= M && M <= a[i + 1]) {
			l = max(l,a[i]);
			r = min(r,a[i + 1]);
		}
	}

	if (M - l <= r - M) {
		cout << a[n - 1] << " " << l << endl;
	}
	else {
		cout << a[n - 1] << " " << r << endl;
	}
}

Measured memory_bytes: 640
using System;
using System.Linq;
namespace aaaaaaaaaaaa
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Trim().ToCharArray().Select(_ => int.Parse(_.ToString())).Sum();
            Console.WriteLine(a % 9 == 0 ? "Yes" : "No");
        }
    }
}


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

int a, b;

int main(){
  cin >> a >> b;
  string s = "";

  for(int i = 0; i < max(a, b); i++)
    s += to_string(min(a, b));

  cout << s << endl;
  return 0;
}

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

int main(){
    int A[9], ma = -1;
    REP(i, 9){
        cin >> A[i];
        ma = max(ma, A[i]);
    }

    int a1, a2, a3, b1, b2, b3, cnt, f = 0;
    for(int i = 0; i <= A[0]; i++){
        cnt = 0;
        b1 = A[0] - i;
        b2 = A[1] - i;
        b3 = A[2] - i;
        a2 = A[3] - b1;
        a3 = A[6] - b1;
        if(a2 + b2 == A[4]){
            cnt++;
        }
        if(a2 + b3 == A[5]){
            cnt++;
        }
        if(a3 + b2 == A[7]){
            cnt++;
        }
        if(a3 + b3 == A[8]){
            cnt++;
        }
        if(cnt == 4){
            f = 1;
            break;
        }
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long n,i,a[200],f=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]%2==0)
        {
            if(a[i]%3!=0&&a[i]%5!=0)
            {
                f++;
            }
        }
    }
    if(f>0)
    {
        cout<<"DENIED"<<endl;
    }
    else
    {
        cout<<"APPROVED"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3544
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
/**
*超时有可能是输入的问题
*注意边界
*仔细读题
*没思路试试逆向思维
**加油，奥利给！！！ 
**/
map<int,int>p;
/*struct knd{
	int x,y,z;
}s[200000];*/ 
int a[200000];
int main()
{
	ll m,n,i,j,t,k,w,e;
	double q;
	cin>>n>>m;
	ll s=0;
	for(i=1;i<=n;i++)
	{
		cin>>t>>k;
		q=sqrt(t*t+k*k);
		if(q<=m) s++;
	 } 
	 cout<<s;
 } 

Measured memory_bytes: 3160
<?php
	fscanf(STDIN,'%d%d',$h,$w);
	for($i=0;$i<$w+2;$i++)echo"#";
	echo"\n";
	for($i=0;$i<$h;$i++){
		$s=fgets(STDIN);
		$s=chop($s);
		echo"#".$s."#\n";
	}
	for($i=0;$i<$w+2;$i++)echo"#";
	echo"\n";


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

int main(int argc, char const *argv[])
{
	long long n;
	cin>>n;
	long long ans=n+1LL;
	for (long long i = 2LL; i*i <= n; ++i)
	{
		if (n%i==0LL)
		{
			ans=min(ans,i+n/i);
		}
	}
	cout<<ans-2LL<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream> 
#include <math.h>
using namespace std;
long long int H,W;
/*
int main()
{
	cin >> W >> H;

 	if(W==1&&H==1) cout<<1<<endl;
	else if(W%2==0) cout<<W/2*H<<endl;
	else 
	{
		if(H%2==0)
			cout<<(W/2+1)*H/2+(W/2)*H/2<<endl;
		else
			cout<<(W/2+1)*(H/2+1)+(W/2)*(H/2)<<endl;
	}	

}

*/
int main()
{
	long double A,B,C;
	cin>>A>>B>>C;
	if((C-A-B)>0&&(C-A-B)*(C-A-B)>4*A*B)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 3756
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    vll x(n), y(n), p(n);
    rep(i, n) cin >> x[i] >> y[i] >> p[i];

    vvll dx(1 << n, vll(n)), dy(1 << n, vll(n));
    for(ll s = 0; s < 1 << n; s++) {
        for(ll i = 0; i < n; i++) {
            dx[s][i] = abs(x[i]);
            dy[s][i] = abs(y[i]);
            for(ll j = 0; j < n; j++) {
                if(s >> j & 1) {
                    chmin(dx[s][i], abs(x[i] - x[j]));
                    chmin(dy[s][i], abs(y[i] - y[j]));
                }
            }
        }
    }

    vll ans(n + 1, INFL);
    for(ll i = 0; i < 1 << n; i++) {
        ll cnt = __builtin_popcount(i);
        for(ll j = i; j >= 0; j--) {
            j &= i;
            ll cost = 0;
            for(ll k = 0; k < n; k++) {
                if(i >> k & 1) continue;    // skip. dist is 0
                cost += min(dx[j][k], dy[i - j][k]) * p[k];
            }
            chmin(ans[cnt], cost);
        }
    }

    for(auto& i : ans) cout << i << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 12972
// https://atcoder.jp/contests/abc139/tasks/abc139_e
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

bool judge[1000][1000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t, cnt = 0;
    cin >> n;
    vector<queue<int>> q(n);
    REP(i, n) REP(j, n - 1) {
        cin >> t;
        q[i].push(t - 1);
    }
    vector<int> sl(n);
    iota(ALL(sl), 0);
    while (true) {
        // 全てのキューが空なら終了
        if (sl.size() == 0) {
            break;
        }
        vector<int> sk;
        bool nfound = true;
        // 前回更新したペアのみ
        for (auto i : sl) {
            int sp = q[i].front();
            judge[i][sp] = true;
            if (judge[sp][i]) {
                nfound = false;
                q[i].pop();
                q[sp].pop();
                if (!q[i].empty()) {
                    sk.push_back(i);
                }
                if (!q[sp].empty()) {
                    sk.push_back(sp);
                }
            }
        }
        if (nfound) {
            cout << "-1\n";
            return 0;
        }
        sl = sk;
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 5632
N, M, X, Y = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
xs.sort()
ys.sort()
for z in range(X + 1, Y + 1):
    if xs[-1] < z <= ys[0]:
        print('No War')
        break
else:
    print('War')

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

int main(){
    int N;cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++)cin>>a.at(i);

    int q;cin>>q;
    vector<int> b(q);
    for(int i=0;i<q;i++)cin>>b.at(i);

    int count=0;
    for(int i=0;i<q;i++){
        for(int j=0;j<N;j++){
            if(b.at(i)==a.at(j)){
                count++;
                break;
            }
        }
    }
    
    cout<<count<<endl;

    return 0;
}


Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 10007;

	void run() {
		int N = sc.nextInt();
		String S = sc.next();
		int[][] dp = new int[N][1 << 3];
		for (int i = 0; i < N; i++) {
			if (i == 0) {
				for (int j = 0; j < 8; j++) {
					if ((j & 1) > 0 && (j & c_to_i(S.charAt(0))) > 0) {
						dp[i][j] = 1;
					}
				}
			} else {
				for (int j = 0; j < 8; j++) {
					for (int k = 0; k < 8; k++) {
						if ((j & k) > 0 && (k & c_to_i(S.charAt(i))) > 0) {
							dp[i][k] = (dp[i][k] + dp[i - 1][j]) % MOD;
						}
					}
				}
			}
		}
		int ans = 0;
		for(int i=0;i<8;i++) ans = (ans + dp[N-1][i]) % MOD;
		System.out.println(ans);
	}

	int c_to_i(char c) {
		switch (c) {
		case 'J': return 1;
		case 'O': return 2;
		case 'I': return 4;
		}
		return -1;
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26396
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
//typedef long long ll;
//typedef long double ld;
//typedef unsigned long long ull;
//typedef unsigned long double uld;
typedef pair<int,int> P;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//struct area

//function area

//main area
int main(){
    int h, w;
    cin >> h >> w;
    vector<string> field(h);
    rep(i, h){
        cin >> field[i];
    }
    rep(i, 2*h){
        rep(j, w){
            cout << field[i/2][j];
        }
        cout << endl;
    }
}
/*



*/

Measured memory_bytes: 3656
/*
    oj d https://atcoder.jp/contests/abc166/tasks/abc166_c
    g++ C.cpp
    oj t
    oj s https://atcoder.jp/contests/abc166/tasks/abc166_c C.cpp
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
 
int main(){
    int N, M;
    cin >> N >> M;
    int H[N];
    for(int i=0;i<N;i++)
        cin >> H[i];
    int A[M], B[M];
    for(int i=0;i<M;i++)
        cin >> A[i] >> B[i];

    int v[N] = {};
    for(int i=0;i<M;i++){
        if(H[A[i]-1] >= H[B[i]-1]){
            v[B[i]-1] = 1;
        }
        if(H[A[i]-1] <= H[B[i]-1]){
            v[A[i]-1] = 1;
        }
    }

    int ans = 0;
    for(int i=0;i<N;i++){
        if(v[i] == 0)
            ans++;
    }

    cout << ans << endl;

}

Measured memory_bytes: 5188
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n) cin>>v[i];
    int ans = 0;
    reverse(v.begin(),v.end());
    int now = 0;
    for(int i = 0; i<n-1;i++){
        if(v[i]<=v[i+1]){
            now++;
            ans = max(now,ans);
        }
        else{
            now = 0;
        }   
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
letterlist = ['N', 'E', 'S', 'W']
S = input()
news = [False, False, False, False]
for i in range(0, len(S)):
	for j in range(0, 4):
		if S[i] == letterlist[j]: news[j] = True
if (news[0]^news[2]) or (news[1]^news[3]): print('No')
else: print('Yes')

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

int main() {
  int N, A, rest_N;
  cin >> N >> A;
  
  rest_N = N % 500; //Nを500で割った余り
  if ( A - rest_N >= 0 ) {
  	cout << "Yes" << endl;
  }else {
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
K = int(input())
A = list(map(int, input().split()))

def is_ok(arg,flg):
  # 条件を満たすかどうか？問題ごとに定義
  N0 = arg
  for a in A:
    N0 -= N0 % a
  if flg:
    return  N0 >= 2
  else:
    return  N0 <= 2
    
def meguru_bisect(ng, ok, flg):
  '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
  '''
  while (abs(ok - ng) > 1):
    mid = (ok + ng) // 2
    if is_ok(mid, flg):
      ok = mid
    else:
      ng = mid
    #print(ok,ng)
  return ok
      
ok,ng = K * max(A) + 100, -1
m = meguru_bisect(ok,ng,False)
#print()
ok,ng = 0, K * max(A) + 100
M = meguru_bisect(ok,ng,True)

if M <= m:
  print(M,m)
else:
  print(-1)

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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------
int dp[101][4][4][4]; //AGCT -> 0123

//def function
//------------------------------------------

//main
//------------------------------------------

int main(){
  int N, M, C;
  cin >> N >> M >> C;
  VI B(M);
  REP(i, M) cin >> B.at(i);
  VVI A(N, VI(M));
  REP(i, N){
    REP(j, M){
      cin >> A.at(i).at(j);
    }
  }

  int count=0;
  REP(i, N){
    int sum=C;
    REP(j, M) sum+=A.at(i).at(j)*B.at(j);
    if(sum>0)count++;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
a1, b1 = gets.chomp.split(" ").map(&:to_i);
a2, b2 = gets.chomp.split(" ").map(&:to_i);
a3, b3 = gets.chomp.split(" ").map(&:to_i);
ary = [a1, b1, a2, b2, a3, b3] 
cnt = 0

4.times do |i|
  if ary.count(i + 1) > 2
    cnt += 1
    break
  end
end
if cnt == 0
  puts 'YES'
else
  puts 'NO'
end

Measured memory_bytes: 1788
/* Coached by rainboy */
#include <stdio.h>
#include <string.h>

#define N 50
#define M 50

int di[] = { -1, 1, 0, 0 };
int dj[] = { 0, 0, -1, 1 };

int main() {
	static char cc[N][M + 1];
	static int dd[N][M], qq[N * M];
	int n, m, i, j, head, cnt;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%s", cc[i]);
	for (i = 0; i < n; i++)
		memset(dd[i], 0x3f, m * sizeof *dd[i]);
	head = cnt = 0;
	dd[0][0] = 0, qq[head + cnt++] = 0 * m + 0;
	while (cnt) {
		int ij, d, h;

		ij = qq[cnt--, head++], i = ij / m, j = ij % m;
		d = dd[i][j] + 1;
		if (i == n - 1 && j == m - 1) {
			cnt = 0;
			for (i = 0; i < n; i++)
				for (j = 0; j < m; j++)
					if (cc[i][j] == '#')
						cnt++;
			printf("%d\n", n * m - cnt - d);
			return 0;
		}
		for (h = 0; h < 4; h++) {
			int i_ = i + di[h], j_ = j + dj[h];

			if (i_ >= 0 && i_ < n && j_ >= 0 && j_ < m && cc[i_][j_] == '.' && dd[i_][j_] > d)
				dd[i_][j_] = d, qq[head + cnt++] = i_ * m + j_;
		}
	}
	printf("-1\n");
	return 0;
}


Measured memory_bytes: 128