akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	int a,b,c,d,e,f,k,l,m,n,x,y,z;
	String ans = "Yes";
	String[] S;
	boolean flg=false;

	Main(){
		// 文字列の入力
		String s = sc.next();
		S = s.split("");

		for(String str:S){
			if(flg){
				if(str.equals("R")){
					ans = "No";
					break;
				}
              	flg = false;
			} else {
				if(str.equals("L")){
					ans = "No";
					break;
				}
              	flg = true;
			}
		}

		// 出力
		System.out.println(ans);
	}

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

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;
bool isSquare(int n) {
	int d = (int)sqrt(n) - 1;
	while (d * d < n) ++d;
	return d * d == n;
}

int main(){
int N, D; cin >> N >> D;
 vector<vector<int>> X(N, vector<int>(D));
 for (int i = 0; i < N; ++i) {
 for (int j = 0; j < D; ++j) {
 cin >> X[i][j];
 }
 }
 int ans = 0;
 for (int i = 0; i < N; ++i) {
 for (int j = i+1; j < N; ++j) {
 int norm = 0;
 for (int k = 0; k < D; ++k) {
 int diff = abs(X[i][k] - X[j][k]);
 norm += diff * diff;
 }
 // check whether norm = k for some k
 bool flag = false;
 for (int k = 0; k <= norm; ++k) {
 if (k * k == norm) {
 flag = true;
 }
 }
 if (flag) ++ans;
 }
 }
 cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        sc.nextLine();
        
        int A[][] = new int[n][m];
        int B[][] = new int[m][l];
        
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                A[i][j] = sc.nextInt();
            }
            sc.nextLine();
        }
        
        for(int i=0;i<m;i++){
            for(int j=0;j<l;j++){
                B[i][j] = sc.nextInt();
            }
            sc.nextLine();
        }
        
        long C[][] = new long[n][l];
        
        for(int i=0;i<n;i++){
            for(int j=0;j<l;j++){
                for(int k=0;k<m;k++){
                    C[i][j] += A[i][k]*B[k][j];
                }
            }
        }
        
        for(int i=0;i<n;i++){
            for(int j=0;j<l;j++){
                if(j == 0){
                    System.out.print(C[i][j]);
                }else{
                    System.out.print(" "+C[i][j]);
                }
            }
            System.out.println();
        }
        
    }
}


Measured memory_bytes: 58284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define sz(s) (ll)s.size()
#define print(d) cout << fixed << setprecision(15) << d
#define pii pair<ll,ll>
#define ppii pair<ll,pii>
#define ff first
#define ss second
const ll MOD = 1000000007;
const ll MAXN = 1e6 + 5;
const ll inf = 2e18;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
tree_order_statistics_node_update> ord_set;
#define debug(x) cerr << #x << " = " << x << endl


ll power(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 

ll sum(ll v)
{
   ll ans=v;
   ans*=(v+1ll);
   ans/=2;
   return ans;
} 


int main()
{
    fast
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ll h,w,n;
    cin >> h >> w >> n;
    ll ans = ceil((n+0.0)/max(h,w));
    cout << ans; 
    return 0;

}










Measured memory_bytes: 256
solve op a b =
  let a' = (read :: String -> Int) a
      b' = (read :: String -> Int) b in
    if op == ['+']
      then a' + b'
      else a' - b'

main = do
  line <- getLine
  let [a, op, b] = words line in
    putStrLn $ show $ solve op a b


Measured memory_bytes: 508
import java.util.Scanner

fun main(args: Array<String>) {
    val s = Scanner(System.`in`)
    val n = s.nextInt()
    val a: MutableList<Int> = mutableListOf()
    for (i in 1..n) {
        a.add(s.nextInt())
    }

    println(solve(a))
}

fun solve(a: List<Int>): Int {
    var r: Int = 0
    for (i in a) {
        r = gcd(r, i)
    }
    return r
}

fun gcd(a: Int, b: Int): Int {
    if (b == 0) {
        return a
    }

    return gcd(b, a % b)
}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();


int main() {
  int64_t N, P;
  cin >> N >> P;
  vector<int> bucket(pow(10, 6) + 100, 0);
  int64_t n = 2;
  int64_t temp = P;
  while (n * n <= P) {
    // cout << n << endl;
    while (temp % n == 0) {
      temp /= n;
      bucket.at(n)++;
    }
    n++;
  }
  // REP(i, 200) {
  //   cout << bucket.at(i) << ' ';
  // }
  // cout << endl;
  int64_t ans = 1;
  if (N == 1) ans = P;
  else {
    for (int i = 0; i < pow(10, 6) + 100; i++) {
      // cout << i << ' ' << bucket.at(i) / N << endl;
      ans *= pow(i, bucket.at(i) / N);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>
#define n 36

struct Card{
  char suit;
  char value;
};

void BubbleSort(struct Card C[],int N){
  int i,j;
  struct Card a;

  for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--){
      if(C[j].value < C[j-1].value){
        a = C[j];
        C[j] = C[j-1];
        C[j-1] = a;
      }
    }
  }
}
void SelectionSort(struct Card C[],int N){
  int i,j,minj;
  struct Card a;

  for(i=0;i<N;i++){
    minj = i;
    for(j=i;j<N;j++){
      if(C[j].value < C[minj].value){
        minj = j;
      }
    }
    a = C[i];
    C[i] = C[minj];
    C[minj] = a;
  }
}

int isStable(struct Card C1[],struct Card C2[],int N){
  int i,j;

  for(i=0;i<N;i++){
    if(C1[i].suit != C2[i].suit)return 0;
  }
  return 1;
}
/*for(i=0;i<N;i++){                                                           
    for(j=i+1;j<N;j++){                                                         
      for(a=0;a<N;a++){                                                         
        for(b=a+1;b<N;b++){                                                     
        if(in[i] == in[j] && )*/
int main(){
  struct Card C1[101],C2[101];
  int i,N;

  scanf("%d\n",&N);
  for(i=0;i<N;i++){
    if(i!=N-1)scanf("%c%c ",&C1[i].suit,&C1[i].value);
    else scanf("%c%c",&C1[i].suit,&C1[i].value);
  }

  for(i=0;i<N;i++)C2[i] = C1[i];

  BubbleSort(C1,N);
  SelectionSort(C2,N);

  for(i=0;i<N;i++){
    if(i)printf(" ");
    printf("%c%c",C1[i].suit,C1[i].value);
  }
  printf("\nStable\n");
  for(i=0;i<N;i++){
    if(i)printf(" ");
    printf("%c%c",C2[i].suit,C2[i].value);
  }
  if(isStable(C1,C2,N)){
    printf("\nStable\n");
  }
  else printf("\nNot stable\n");

  return 0;
}




Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N;
    ll ans=0;
    cin >> N;
    const auto &res = prime_factorize(N);
    //cout << N << ":";
    for (auto p : res) {
        ll num = p.second;
        //for (int i = 0; i < p.second; ++i) cout << " " << p.first;
        ll now =1;
        while(num>0){
            num-=now;
            now++;
            if(num>=0)ans++;
        }
    }
    cout << ans <<endl;
}

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

int main(){
  char s[4]; scanf("%s",s);
  char c = s[0];
  char d;
  bool bad = false;
  for(int i=1;i<4;i++){
    d = s[i];
    if(c==d){bad = true;break;}
    c = d;
  }
  cout << (bad?"Bad":"Good") << "\n";
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input()) 

ans = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if (i*500) + (j*100) + (k*50) == X:
                ans = ans + 1 

print(ans)

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

int main() {
  string k;
  cin >> k;
  int count = 700;
  
  for(int i = 0; i < 3; i++) {
    if(k[i] == 'o') {
      count += 100;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
import sys
ab = []
for line in sys.stdin:
    temp = list(map(int, line.split()))
    if temp == [0, 0]:
        v = [0 for i in range(max(ab)+1)]
        for i in ab:
            v[i] += 1
        odd = 0
        for i in v:
            if i % 2 == 1:
                odd += 1
        if odd == 2 and ((v[1] % 2) == (v[2] % 2) == 1):
            print('OK')
        else:
            print('NG')
        ab = []
    else:
        ab += temp



Measured memory_bytes: 5612
package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
	"strconv"
)

func reverseString(s string) string {
	n := len(s)
	bytes := []byte(s)
	for i := 0; i < n/2; i++ {
		bytes[i], bytes[n-1-i] = bytes[n-1-i], bytes[i]
	}
	return string(bytes)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100001), 100001*100)

	s := next()
	l := list.New()
	for _, c := range s {
		l.PushBack(string(c))
	}
	q := nextInt()

	rev := false

	for i := 0; i < q; i++ {
		t := nextInt()
		switch t {
		case 1:
			rev = !rev
		case 2:
			f, c := nextInt(), next()
			if (!rev && f == 1) || (rev && f == 2) {
				l.PushFront(c)
			} else {
				l.PushBack(c)
			}
		}
	}

	if !rev {
		for e := l.Front(); e != nil; e = e.Next() {
			putf("%s", e.Value.(string))
		}
	} else {
		for e := l.Back(); e != nil; e = e.Prev() {
			putf("%s", e.Value.(string))
		}
	}
	putf("\n")

	wt.Flush()
}

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}


Measured memory_bytes: 26880
#include <bits/stdc++.h>
#define ll long long
#define tezina second
#define vrednost first
#define inf 1000000010

using namespace std;

ll n, kapacitet, maxvr;
pair<ll,ll> predmeti[110];

    ll dp[100100][110];

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

    cin>>n>>kapacitet;
    maxvr=100010;
    ll t, v;
    for(int i=1;i<=n;i++)
    {
        cin>>t>>v;
        predmeti[i]=make_pair(v,t);
    }
    sort(predmeti,predmeti+n+1);

    for(int i=1;i<=maxvr;i++)
    {
        for(int j=0;j<=n;j++)
            dp[i][j]=inf;
    }


    for(int i=1;i<=maxvr;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(predmeti[j].vrednost<=i)
				dp[i][j]=min(dp[i][j-1],dp[i-predmeti[j].vrednost][j-1]+predmeti[j].tezina);
			else
				dp[i][j]=dp[i][j-1];
        }
    }
    for(int i=maxvr-1;i>=0;i--)
        if(dp[i][n]<=kapacitet)
        {
            cout<<i;
            return 0;
        }
    cout<<dp[0][n];


	return 0;
}


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

typedef long long ll;

ll a,b,c;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>a>>b>>c;
    if(c<=a+b){
        cout<<"No"<<endl;
        return 0;
    }
    if((c-a-b)*(c-a-b)>4*a*b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}


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

int main(){

 long N, P;
 long i, j;
 long A[1000000];
 long ans = 1;

 scanf("%ld %ld", &N, &P);

 if(P == 1){
   ans = 1;
   goto Ans;
 }

 if(N == 1){
   ans = P;
   goto Ans;
 }

 i = pow(P, 1/double(N));
 for( j=2 ; j<=i ; P%j==0 ? : j++ ){
   if(P%j == 0){
     P /= j;
     A[j]++;
   }
 }

 for( j=2 ; j<=i ; j++){
   A[j] = A[j]/N;
   if(A[j]) ans *= pow(j, A[j]);
 }

 Ans: ;
 printf("%ld\n", ans);
 return 0;
}



Measured memory_bytes: 7424
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())


S = input()
T = input()
ans = 0
for i in range(len(S)):
    if S[i] == T[i]:
        ans += 1
print(ans)

Measured memory_bytes: 14292
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn :: IO Int
  s <- BS.getLine
  let a = BS.foldl' (\n c -> if c == 'R' then n + 1 else n) 0 s
      b = n - a
  if a > b
    then putStrLn "Yes"
    else putStrLn "No"


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

#define int            long long int
#define float          long double
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define inf            1e18
#define set_pre(x,y)   fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
using namespace std;
int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int dp[3001][3001];
int solve(int i,int j,vector<int>&v)
{
    if(i>j)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(j-i==1)
        return max(v[i],v[j]);
    else return dp[i][j]=max(min(solve(i+1,j-1,v),solve(i+2,j,v))+v[i],min(solve(i+1,j-1,v),solve(i,j-2,v))+v[j]);
}
int32_t main(){
    int n;
    cin>>n;
    vector<int>v(n);
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        sum+=v[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            dp[i][j]=-1;
        }
    }
    int x=solve(0,n-1,v);
    cout<<2*x-sum<<endl;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, cnt[3];
long long ans;
char s[4005];
int main(){
	scanf("%d\n%s", &n, s);
	rep(i,n) cnt[s[i]=='R'?0:s[i]=='G'?1:2]++;
	ans = (long long)cnt[0] * cnt[1] * cnt[2];
	rep(i,n) for(int j=1; i+j*2<n; j++) if(s[i] != s[i+j] && s[i] != s[i+j*2] && s[i+j] != s[i+j*2]) ans--;
	printf("%lld\n", ans);
}

Measured memory_bytes: 3828
from collections import deque
from itertools import product


def bfs(x, y):
    dist = [[10 ** 9] * w for _ in range(h)]
    dist[y][x] = 0
    que = deque([(x, y)])

    while len(que) > 0:
        x, y = que.popleft()
        near_a = [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]
        num = product([-2, -1, 0, 1, 2], repeat=2)
        near_b = [(x + dx, y + dy) for dx, dy in num]
        if (x, y) == (Dw - 1, Dh - 1):
            return dist[y][x]

        for cnt, l in enumerate((near_a, near_b)):
            for i, j in l:
                if (0 <= i < w and 0 <= j < h and
                        dist[j][i] > dist[y][x] + cnt and s[j][i] == '.'):
                    dist[j][i] = dist[y][x] + cnt
                    if cnt == 0:
                        que.appendleft((i, j))
                    elif cnt == 1:
                        que.append((i, j))
    return -1


h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
s = [input() for _ in range(h)]

print(bfs(Cw - 1, Ch - 1))


Measured memory_bytes: 97240
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <tuple>

using namespace std;

using P = pair<int, int>;
using i64 = int64_t;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;

int main(int argc, char **argv) {
    int n;
    cin >> n;
    int ans;

    if (n > 9) {
        ans = 9;
        if (n > 999) {
            ans += 900;
            if (n > 99999) {
                --n;
            }
            ans += max(n-9999, 0);
        } else {
            ans += max(n-99, 0);
        }
    } else {
        ans = n;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define io std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const double pi=acos(-1);
const ll P = 998244353, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n){ll r=1%P;for (a%=P; n; a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
const double eps=1e-5;
ll lcm(ll a,ll b){return a*b/gcd(a,b);};



const int maxn = 1e5+10;
int sum1[maxn],sum2[maxn];
int main(){
    int n,k;
    cin>>n>>k;
    std::vector<int> ans1,ans2;
    for(int i=1;i<=n;i++)
      {
            int x;
            cin>>x;
            if(x<0)ans1.push_back(-x);
            else if(x>0) ans2.push_back(x);
            else k--;
      }
      reverse(ans1.begin(),ans1.end());
      for(int i=0;i<ans2.size();i++)
      { 
        sum1[i+1]=ans2[i];
      }
      for(int i=0;i<ans1.size();i++)
      {
        sum2[i+1]=ans1[i];
      }
      int _min=1e9+10;
      if(k==0)
        _min=0;
      for(int i=1;i<=ans2.size();i++){
        if(k-i>ans1.size())
          continue;
        _min=min(sum1[i]+sum2[k-i]+min(sum1[i],sum2[k-i]),_min);
      }
      for(int i=1;i<=ans1.size();i++)
      {if(k-i>ans2.size())
          continue;
        _min=min(sum2[i]+sum1[k-i]+min(sum2[i],sum1[k-i]),_min);
      }
      cout<<_min<<endl;
    return 0;
}

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

using namespace std;

int main() {
    int N, K, S, T;
    cin >> N >> K >> S >> T;

    vector<map<pair<int,int>,long long>> dp(K+1);
    dp[0][{(1<<18)-1, 0}] = 1;

    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        if ((a & S) != S) continue;
        if ((a | T) != T) continue;
        for (int k = K-1; k >= 0; --k) {
            for (auto& p : dp[k]) {
                int prod, sum; tie(prod, sum) = p.first;
                dp[k+1][{prod & a, sum | a}] += p.second;
            }
        }
    }

    long long ans = 0;
    for (int k = 1; k <= K; ++k) {
        ans += dp[k][{S, T}];
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;   
int main(){
	char s[104];
	int i,len,sum=0;
	cin >> s;
	len=strlen(s);
	for(i=0;i<len/2;i++){
		if(s[i]!=s[len-i-1]){
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>

int main(){
  int n,q,key,i,j,count=0;
  int S[10000];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    for(j=0;j<n;j++)
      if(S[j]==key){
	count++;
	break;
      }
  }

  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 640
using System;

class Program
{
    static void Main()
    {
        var s = Console.ReadLine();
        if (s == "Sunny")
        {
            Console.WriteLine("Cloudy");
        }
        else if (s == "Cloudy")
        {
            Console.WriteLine("Rainy");
        }
        else
        {
            Console.WriteLine("Sunny");
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;


int main() {
    
    int N = 0;
    cin >> N;
    vector<unsigned int> L;
    vector<unsigned int> pop;
    unsigned int temp = 0;
    unsigned int count = 0;
    for (int i = 0; i < N; i++) {
        cin >> temp;
        L.push_back(temp);
    }
    sort(L.begin(), L.end());
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                if(L[i] != L[j] && L[i] != L[k] && L[j] != L[k]){
                    if (L[i] + L[j] > L[k]) {
                        count += 1;
                    }
                }
            }
        }
    }
    cout << count;

    return 0;
}

Measured memory_bytes: 3180
#include<stdio.h>
int main()
{
	int N, X, L[10010],sum=0,count=0;
	scanf("%d%d", &N, &X);
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &L[i]);
	}
	for (int i = 0; i < N; i++)
	{	
		sum += L[i];
		if (sum<= X)
		{
			count++;
		}
	}
	printf("%d", count + 1);
	return 0;
}


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

int main()
{
    ll n,a,b,c,d;
    a=b=c=d=0;
    cin>>n;
    while(n--)
    {
        string str;
        cin>>str;
        if(str=="AC")
        {
            a++;

        }
        else if(str=="WA")
        {
            b++;
        }
        else if(str=="TLE")
        {
            c++;
        }
        else d++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;


}



Measured memory_bytes: 3612
#include <cstdio>
int main(){
 int i,j,h,w;
 while(true){
  scanf("%d %d",&h,&w);
  if ((h==0)&&(w==0)) break;
  for(i=0;i<h;i++){
   for(j=0;j<w;j++){
    printf((i+j)%2==0?"#":".");
   };
   printf("\n");
  }
  printf("\n");
 }
 return 0;
};

Measured memory_bytes: 1020
n = int(input())
a_list = [int(col) for col in input().split(' ')]

min_score = None
for target in range(-100, 101):
  score = 0
  for a in a_list:
    score += (target - a) * (target - a)
  if min_score is None or min_score > score:
    min_score = score
print(min_score)

Measured memory_bytes: 3064
#include<iostream>
#include<numeric>
#include<math.h>
#include<cmath>
using namespace std;
using ll = long long int;
constexpr ll MOD = 2019;

ll l, r;

int main(void) {
	cin >> l >> r;
	ll ret=2018;
	if (l / MOD < r / MOD)
		ret = 0;
	else {
		for (ll i = l; i < r; i++) {
			for (ll j = i + 1; j <= r; j++) {
				ll tmp = (i % MOD) * (j % MOD) % MOD;
				if (tmp < ret)
					ret = tmp;
			}
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 764
import sys
N = int(input())
W = [input()]

for i in range(1,N):
    W.append(input())
    if W[i-1][-1] != W[i][0]:
        print("No")
        sys.exit()
    for j in range(i):
        if W[j] == W[i]:
            print("No")
            sys.exit()
print('Yes')

Measured memory_bytes: 3060
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    ll k; cin >> k;
    ll n = s.size();
    ll ans = 0;
    ll cnt = 1;
    if(s[0] != s[n - 1]) {
        rep(i, 0, n - 1) {
            if(s[i] == s[i + 1])
                cnt++;
            else {
                ans += cnt / 2;
                cnt = 1;
            }
        }
        ans += cnt / 2;
        ans *= k;
    } else {
        ll pos = 0;
        while(pos < n && s[pos] == s[0]) pos++;
        if(pos == n) {
            ans = n * k / 2;
            cout << ans << "\n";
            return 0;
        }
        rep(i,pos, n-1) {
            if(s[i] == s[i + 1]) {
                cnt++;
            } else {
                ans += cnt / 2;
                cnt = 1;
            }
        }
        debug(ans, pos, cnt);
        ans *= k;
        ans += (pos + cnt) / 2 * (k - 1);
        ans += pos / 2 + cnt / 2;
    }

    cout << ans << "\n";
}

Measured memory_bytes: 3580
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
using ll=long long;
using namespace std;
//const int INF = 7+(1e+9);
ll GCD(ll x, ll y)
{
    if (y == 0)
    {
        return x;
    }
    else
    {
        return GCD(y, x % y);
    }
}
ll LCM(ll x, ll y)
{
    return x / GCD(x, y) * y;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
vector<vector<char>> vec(12,vector<char>(12));

int dx[]={0,-1,0,1};
int dy[]={1,0,-1,0};
int dfs(int y,int x){
    vec[y][x]='5';
    for(int i=0;i<4;i++){
        if(x+dx[i]<12&&x+dx[i]>=0&&y+dy[i]<12&&y+dy[i]>=0&&vec[dy[i]+y][dx[i]+x]=='1'){
            dfs(y+dy[i],x+dx[i]);
        }
    }
    return 0;
}

int main(){
    while(1){
        int n,k;
        cin>>n>>k;
        if(n==0&&k==0)break;
        int sum=0;
        for(int i=1;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(k-i-j>j&&k-i-j<=n){
                  //  cout<<i<<" "<<j<<endl;
                    sum++;
                }
            }
        }
        cout<<sum<<endl;
    }
    
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int a[]={1,-1,5,-5,10,-10};

int main() {
    ll V,E,r;
    cin >> V >> E >> r;
    vector<vector<pair<ll,ll>>> G(V);
    for(ll i=0;i<E;i++){
        ll x,y,cost;
        cin >> x >> y >> cost;
        G[x].push_back({y,cost});
    }
    vector<ll> dist(V,INF),used(V,0);
    dist[r]=0;
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> pq;
    pq.push({0,r});
    while(!pq.empty()){
        ll pos,d;
        pos = pq.top().second;
        d = pq.top().first;
        pq.pop();
        if(used[pos]==1)continue;
        used[pos]=1;
        for(auto &x:G[pos]){
            if(dist[x.first]>d+x.second){
                dist[x.first] = d+x.second;
                pq.push({dist[x.first],x.first});
            }
        }
    }
    for(auto &x:dist){
        if(x!=INF)cout << x << endl;
        else cout << "INF" << endl;
    }
}


Measured memory_bytes: 20084
#include<bits/stdc++.h>
using namespace std;
int read()
{
	char s;
	int k=0,base=1;
	while((s=getchar())!='-'&&s!=EOF&&!(s>='0'&&s<='9'));
	if(s==EOF)exit(0);
	if(s=='-')base=-1,s=getchar();
	while(s>='0'&&s<='9')
	{
		k=k*10+(s-'0');
		s=getchar();
	}
	return k*base;
}
void write(int x)
{
	if(x<0)
	{
		putchar('-');
		write(-x);
	}
	else
	{
		if(x/10)write(x/10);
		putchar(x%10+'0');
	}
}
int n,x,ans,Min,Max;
int a[100110];
int main()
{
	n=read();
	while (n--)
	{
		x=read();
		a[x+1]++;
		a[x]++;
		a[x+2]++;
		Max=max(Max,x+1);
	}
	for (int i=0;i<=x+2;i++)
	{
		ans=max(a[i],ans);
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long min, max, sum;
        min = Long.MAX_VALUE;
        max = Long.MIN_VALUE; 
        sum = 0;
        for (int i = 0; i < n; i++) {
            long a = scanner.nextLong();
            if (min > a) min = a;
            if (max < a) max = a;
            sum += a;
        }

        System.out.println(min + " " + max + " " + sum);
    }
}



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

int ord(const void* x, const void* y){
        //const char *a = x, *b=y;

    return strcmp(x,y);
}

int main(){

    int n,m;
    char nome[120][120];
    scanf("%d %d",&n,&m);

    for(int i=0;i<n;i++){
        scanf("%s",nome[i]);
    }

    qsort(nome,n,sizeof(nome[0]),ord);

    for(int i=0;i<n;i++)
        printf("%s",nome[i]);

    puts("");

    return 0;
}


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

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

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

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

	sort(l,l+n);

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

	if(sum > l[n-1]) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<math.h>
#include<assert.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}
int sankaku(int x){return ((1+x)*x)/2;}
void swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}
//小さい順
int compareInt(const void* a, const void* b){int aNum = *(int*)a;int bNum = *(int*)b;return aNum - bNum;}

int main(void){
    int N;
    scanf("%d",&N);
    printf("Christmas");
    for(int i=N;i<25;i++){
        printf(" Eve");
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   string S;
   cin >> N >> S;
   int x = 0;
   int ans = 0;
   for (int i = 0; i < N; i++) {
      if (S[i] == 'I') x++;
      else x--;
      chmax(ans, x);
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double inf=1e-10;
int main(){
	int n;
	double res=0;
	cin>>n;
	vector <double > arr(n,0.0);
	vector <double > dp(n+1,0.0);
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	dp[0]=1;
	for(int coin=0;coin<n;coin++){
		for(int i=n;i>0;i--){
			dp[i]=dp[i]*(1-arr[coin])+(i==0 ? 0 : dp[i-1]*arr[coin]);
		}
		dp[0]=dp[0]*(1-arr[coin]);
	}
	for(int i=n/2+1;i<n+1;i++){
		res+=dp[i];
	}
	printf("%.10f",res);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> doup;

int main(void) {
    ll i, j, N;
    ll c[500], s[500], f[500];
    cin >> N;
    for(i=1; i<N; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }
    ll t;
    ll k;
    for(i=1; i<N; i++) {
        t=s[i]+c[i];
        for(j=i+1; j<N; j++) {
            if(t<s[j]) {
                t=s[j];
            }else {
                k=(t-s[j])/f[j]+((t-s[j])%f[j]==0 ? 0 : 1);
                t+=s[j]+f[j]*k-t;
            }
            t+=c[j];
        }
        
        cout << t << endl;
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
A = list(map(int,input().split()))
B = []
ans = 0
 
for i in range (0,N):
  A[i] = A[i] - (i + 1)

median = np.median(A)

for i in range (0,N):
  ans = ans + abs(A[i] - median)
print(int(ans))

Measured memory_bytes: 34208
using System.Linq;
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var b0 = new List<int>();
        var b1 = new List<int>();
        line = Console.ReadLine().Trim().Split(' ');
        for (int i = 0; i < n; i++)
            if (line[i] == "0") b0.Add(i);
            else b1.Add(i);

        line = Console.ReadLine().Trim().Split(' ');
        var p0 = new List<int>();
        var p1 = new List<int>();
        var pos = 0;
        var wsum = 0;
        for (int i = 0; i < m; i++)
        {
            var w = int.Parse(line[i]);
            if (i % 2 == 0) getPos(p0, pos + wsum, w);
            else getPos(p1, pos + wsum, w);
            wsum += w;
        }
        if (b0.Count() == b1.Count())
            Console.WriteLine(Math.Min(getAns(b0, p0), getAns(b0, p1)));
        else if (b0.Count() == p0.Count()) Console.WriteLine(getAns(b0, p0));
        else if (b0.Count() == p1.Count()) Console.WriteLine(getAns(b0, p1));
    }
    public static int getAns(List<int> a, List<int> b)
    {
        var ret = 0;
        for (int i = 0; i < a.Count(); i++)
            ret += Math.Abs(a[i] - b[i]);
        return ret;
    }
    public static void getPos(List<int> a, int pos, int w)
    {
        for (int i = 0; i < w; i++)
            a.Add(i + pos);
    }
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    cout<<"2018"+s.substr(4,6)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun next(X: IntArray, popCount: Int): Int {
        var ans = 0
        var d = 1
        for (i in X.count() - 1 downTo 0) {
            if (X[i] == 1) {
                ans += d % popCount
                ans %= popCount
            }
            d *= 2
            d %= popCount
        }
        return ans
    }

    private fun popCount(X: Int): Int {
        var i = X
        var ans = 0
        do {
            ans += i and 1
            i /= 2
        } while (i > 0)
        return ans
    }

    fun next(X: Int): Int {
        var ans = 0
        var d = 1
        val div = popCount(X)
        var x = X
        while (x > 0) {
            if (x and 1 == 1) {
                ans += d % div
                ans %= div
            }
            d *= 2
            d %= div
            x /= 2
        }
        return ans
    }

    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val X = sc.next().map { it.toInt() - 48 }.toIntArray()

        val nxt = IntArray(N)
        for (i in 1 until N) {
            nxt[i] = next(i)
        }

        val nxt2 = IntArray(N)
        val popCount = X.count { it == 1 }
        val popCountMinus = popCount - 1
        val popCountPlus = popCount + 1
        val nxtMinus = if (popCountMinus == 0) -1 else next(X, popCountMinus)
        val nxtPlus = next(X, popCountPlus)
        var dMinus = 1
        var dPlus = 1
        for (i in N - 1 downTo 0) {
            if (X[i] == 1) {
                // 1 -> 0
                if (popCountMinus == 0) {
                    nxt2[i] = -1
                } else {
                    nxt2[i] = nxtMinus - dMinus
                    nxt2[i] += popCountMinus
                    nxt2[i] %= popCountMinus
                }
            } else {
                // 0 -> 1
                nxt2[i] = nxtPlus + dPlus
                nxt2[i] %= popCountPlus
            }
            if (popCountMinus != 0) {
                dMinus *= 2
                dMinus %= popCountMinus
            }
            dPlus *= 2
            dPlus %= popCountPlus
        }

        for (i in 0 until N) {
            var x = nxt2[i]
            if (x == -1) {
                pw.println("0")
            } else {
                var ans = 1
                while (x > 0) {
                    x = nxt[x]
                    ans++
                }
                pw.println(ans)
            }
        }
    }
}


Measured memory_bytes: 55380
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  string s; cin >> s;
  ll n = s.size();
  const int mod = 2019;

  Vll x(n+1);

  ll y = 1;
  rep(i, n) {
    x[i+1] = x[i] + (s[n-1-i]-'0') * y; 
    x[i+1] %= mod;
    y *= 10;
    y %= mod;
  }

  Vll cnt(mod);
  ll ans = 0;
  rep(i, n+1) {
    ans += cnt[x[i]];
    ++cnt[x[i]];
  }

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


Measured memory_bytes: 5068
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<typename T>
void chmax(T &a, T b) {
    if (a.size() != b.size()) {
        a = (a.size() < b.size() ? b : a);
    } else {
        a = max(a, b);
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w;
    while (cin >> w >> h, h + w) {
        auto mp = make_v(h, w, -1);
        REP(i, 0, h) {
            REP(j, 0, w) {
                char c;
                cin >> c;
                if ('0' <= c && c <= '9') {
                    c -= '0';
                    mp[i][j] = c;
                }
            }
        }
        auto memo = make_v(h, w, vector<int>());
        function<vector<int>(int, int)> solve = [&](int x, int y) {
            if (memo[y][x].size() != 0) return memo[y][x];
            if (mp[y][x] == -1) return vector<int>();
            vector<int> ans;
            if (y + 1 < h && mp[y + 1][x] != -1) {
                chmax(ans, solve(x, y + 1));
            }
            if (x + 1 < w && mp[y][x + 1] != -1) {
                chmax(ans, solve(x + 1, y));
            }
            ans.insert(ans.begin(), mp[y][x]);
            return memo[y][x] = ans;
        };
        vector<int> ans;
        REP(i, 0, h) {
            REP(j, 0, w) {
                if (mp[i][j] != -1) {
                    auto res = solve(j, i);
                    while (res.size() > 1 && res[0] == 0) {
                        res.erase(res.begin());
                    }

                    chmax(ans, res);
                }
            }
        }
        REP(i, 0, ans.size()) {
            cout << ans[i];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3408
h,w = [int(i) for i in input().split()]
s = [list(input()) for i in range(h)]

def search(y,x):
    if s[y][x] != "#":
        return True
    if s[y][x] == "#":
        for dy,dx in ((1,0),(-1,0),(0,1),(0,-1)):
            ny,nx = (y+dy,x+dx)
            if 0 <= ny <= h-1 and 0 <= nx <= w-1:
                if s[ny][nx] == "#":
                    return True
    return False


for i in range(h):
    for j in range(w):
        if search(i,j) == False:
            print("No")
            exit()
print("Yes")

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

using namespace std;

int a[100010]={};

int main()
{
    int i;
    int n;
    int num;
    int maxs=0;
    while (scanf("%d",&n)!=EOF)
    {
        memset(a,0,sizeof (a));
        for (i=0;i<n;i++)
        {
            scanf("%d",&num);
            a[num]++;
            if (num>maxs)
                maxs=num;
        }
        num=0;
        for (i=0;i<=maxs;i++)
        {
            if (a[i]+a[i+2]+a[i+1]>num)
                num=a[i]+a[i+2]+a[i+1];
        }
        printf("%d\n",num);
        maxs=0;
        num=0;
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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 dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

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 r,x,d;

int main(){
	cin>>r>>d>>x;
	for(int i=0;i<10;i++){
		x=r*x-d;
		cout<<x<<endl;
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<vector<pair<int,int>>> A(N);
  rep(i,N){
    int a;
    cin >> a;
    rep(j,a){
      int x,y;
      cin >> x >> y;
      x--;
      A[i].push_back(make_pair(x,y));
    }
  }
  
  int ans = 0;
  for(int i = 0; i<(1<<N); i++){
    bool flag = true;
    int cnt = 0;
    for(int j = 0; j<N; j++){
      
      if(i & (1<<j)){
        for(auto a : A[j]){
          if((i & (1<<a.first) && 0 == a.second) || (!(i & (1<<a.first)) && 1 == a.second) ){
            flag = false;
          }
        }
        cnt++;
        
      }
      
    }
    if(flag) ans = max(ans,cnt);
    
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256