akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class main
{
    public static void Main()
    {
        int i;
        string y;
        var a = new Queue<Char>();
        var b = new Queue<Char>();
        var c = new Queue<Char>();
        char x='a';
        int WinnerFlag;

        y = ReadLine();
        for (i = 0; i < y.Length; i++)
        {
            a.Enqueue(y[i]);
        }

        y = ReadLine();
        for (i = 0; i < y.Length; i++)
        {
            b.Enqueue(y[i]);
        }

        y = ReadLine();
        for (i = 0; i < y.Length; i++)
        {
            c.Enqueue(y[i]);
        }

        while (true)
        {
            if(x=='a'){
                if (a.Count == 0)
                {
                    WriteLine('A');
                    break;
                }
                x = a.Dequeue();
            }
            else if(x=='b'){
                if (b.Count == 0)
                {
                    WriteLine('B');
                    break;
                }
                x = b.Dequeue();
            }
            else if(x=='c'){
                if(c.Count==0){
                    WriteLine('C');
                    break;
                } 
                x = c.Dequeue();
            }

        }
    }
}

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

using namespace std;

#define rep(i, a, n) for(int i = a; i < (n); ++i)
#define ll long long

int main(){
  int n, k, q;
  cin >> n >> k >> q;

  vector<ll> v(n, k), cnt(n);
  ll a;
  rep(i, 0, q) {
    cin >> a;
    ++cnt[a - 1];
  }
  rep(i, 0, n) {
    if (k + cnt[i] - q  > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

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

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

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

  vector<int> dp(n+1);
  
  fill(dp.begin(), dp.end(), 1000000000);
  
  for (int i = 1; i <= n; i++) {
    if (i == 1) {
      dp[1] = 0; 
    } else if (i  == 2){
      dp[2] = abs(h[1] - h[2]);
    } else {
      for (int j = 1; j <= k; j++) {
        if (0 < i - j) {
          dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i]);
        }
      }
    }
  }

  cout << dp[n] << endl;

}

Measured memory_bytes: 1024
object Main extends App {
  val l1 = io.StdIn.readLine().toInt
  if(l1 == 1) println("Hello World")
  else{
    val l2 = io.StdIn.readLine().toInt
    val l3 = io.StdIn.readLine().toInt
    println(l2 + l3)
  }
}


Measured memory_bytes: 27192
using System;
using System.Collections.Generic;
using System.Linq;
class arrayInput{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    int[] num = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    bool flag = true;
    int count = 0;
    while(flag){
      flag = false;
      for(int i=n-1; i>=1; i--){
        if(num[i] < num[i-1]){
          int temp = num[i];
          num[i] = num[i-1];
          num[i-1] = temp;
          count++;
          flag = true;
        }
      }
    }
    for(int i=0; i<n; i++){
      if(i == n-1){
        Console.WriteLine(num[i]);
      }
      else{
        Console.Write("{0} ",num[i]);
      }
    }
    Console.WriteLine(count);
  }
}



Measured memory_bytes: 18360
S=str(input())
T=str(input())
L=len(T)
result=1000
for i in range(0,len(S)-len(T)+1):
  count=0
  for j in range(len(T)):
    if S[i+j]!=T[j]:
      count+=1
  if result>count:
    result=count
print(result)

Measured memory_bytes: 72884
n,m=map(int,input().split())
edges=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    edges[a-1]+=[b-1]
    edges[b-1]+=[a-1]
vis=[1]+[0]*(n-1)

def dfs(v):
    if vis==[1]*n:
        return 1
    count=0
    for i in edges[v]:
        if vis[i]==0:
            vis[i]=1
            count+=dfs(i)
            vis[i]=0
    else:
        return count
print(dfs(0))


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

using namespace std;

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

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

    vector<int> bucket(101, 0);
    for (int v : vec)
        ++bucket[v];

    int count = 0;
    for (int v : bucket) {
        if (v != 0)
            ++count;
    }

    cout << count << '\n';
}


Measured memory_bytes: 380
#include <stdio.h>

int main(void){
  double a,b,c,d,e,f;
  double x,y;
  
  while (scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF) {
    y = (c * d - a * f) / (b * d - e * a);
    x = (c - (b * y)) / a;
    
    printf("%.3lf %.3lf\n",x,y);
  }   
  return 0;
}

Measured memory_bytes: 648
k = int(input())
s = input()
mod=10**9+7
n=len(s)

framod=[1]
def framod_calc(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
        framod.append(a)
framod_calc(n+k+1, mod)

def combmod(n, k, mod):
    a=framod[n]
    b=framod[k]
    c=framod[n-k]
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod

ans=0
for i in range(k+1):
    ans+=(pow(26, i, mod)*pow(25, k-i, mod))*combmod(n+(k-i)-1, n-1, mod)
    ans%=mod
print(ans)

Measured memory_bytes: 211040
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=101101;
char S[N];
int main(){
	scanf("%s",S);
	int n=strlen(S);
	for (int i=0; i<n; i++)
		printf("x");
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  rep(i, s.size()) {
    if(s[i] == '+') {
      ++ans;
    } else if(s[i] == '-') {
      --ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[100000];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i];
  int diff = *max_element(A, A+N) - *min_element(A, A+N);
  if (diff > 1) {
    cout << "No\n";
    return 0;
  }

  int x = *min_element(A, A+N);
  if (diff == 0) {
    if (N == x || N >= 2*x || x == N-1) cout << "Yes\n";
    else cout << "No\n";
  }
  else {
    // x, x+1
    int ctr = 0;
    rep(i, N) {
      if (A[i] == x) ctr++;
    }
    int lim = (N-ctr)/2;
    if (lim <= 0) {
      cout << "No\n";
      return 0;
    }
    // [ ctr+1 , ctr+lim ]
    if (ctr+1 <= x+1 && x+1 <= ctr+lim) cout << "Yes\n";
    else cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (x, ) = [int(e) for e in lines[0].split(" ")]
    

    return (x, )


def solve(x):

    result = None
    if x == 0:
        result = 1
    else:
        result = 0


    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    int n, m;
    cin >> n >> m;

    int x[m];
    rep(0, m) cin >> x[i];

    sort(x, x+m);

    int d[m];
    d[0] = 0;
    for (int i = 0; i < m; i++) {
        d[i-1] = x[i] - x[i-1];
    }
    sort(d, d+(m-1));

    int ans = 0;
    if (n < m) {
        for (int i = 0; i < ((m-1)-(n-1)); i++) {
            ans += d[i];
        }
    }

    cout << ans << endl;
}

int main() {
    solve();

    return 0;
}


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

const int maxn = 2e5+10;
ll n, a[maxn], countN[maxn], ans;

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

	for(int i=1; i<=n; i++){
		ans += (countN[i]*(countN[i]-1))/2;
	}

	for(int i=0; i<n; i++){
		cout << ans-(countN[a[i]]-1) << endl;
	}
}

Measured memory_bytes: 4736
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

ll calc(ll H, ll W) {
    ll res = 1e10;
    for (ll h1 = 1; h1 < H; h1++) {
        if (h1 != H - 1) {
            ll h2 = (H - h1) / 2, h3 = H - h1 - h2;
            ll dh = max({h1, h2, h3}) - min({h1, h2, h3});
            amin(res, dh * W);
        }
        ll S1 = h1 * W;
        ll S2 = (H - h1) * (W / 2);
        ll S3 = (H - h1) * (W - W / 2);
        amin(res, max({S1, S2, S3}) - min({S1, S2, S3}));
    }
    return res;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W;
    cin >> H >> W;
    cout << min(calc(H, W), calc(W, H)) << "\n";
    return 0;
}


Measured memory_bytes: 256
#problem1
from collections import deque
d=deque()
e=deque()

N=int(input())
graph=[[] for i in range(N+1)]
D=[]
for _ in range(N-1):
    a,b=map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
    D.append((a,b))
    
#頂点1からスタート
K=0
d.append(1)
visited=[False for i in range(N+1)]
color=[-1 for i in range(N+1)]
visited[1]=True
color[1]=-1
dic={}
while d:
    while d:
        x=d.popleft()
        par_color=color[x]
        c=1
        for node in graph[x]:
            if visited[node]==False:
                visited[node]=True
                e.append(node)                
                if c!=par_color:
                    color[node]=c
                    dic[(x,node)]=c
                elif c==par_color:
                    c+=1
                    color[node]=c
                    dic[(x,node)]=c
                c+=1
    if e:
        d=e
        e=deque()

A=max(color)
print(A)
for que in D:
    a,b=que
    if (a,b) in dic.keys():
        print(dic[que])
    else:
        print(dic[(b,a)])
    

Measured memory_bytes: 45168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    cin >> n;
    ll l[256];
    l[0] = 2, l[1]=1;
    for(int i=2;i<=n;i++){
        l[i] = l[i-1] + l[i-2];
    }
    cout << l[n] << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 510000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli N,K,sum=0;
  cin >> N >> K;
  Vecpr(P,lli,lli,N);
  rep(i,0,N)cin >> P[i].first >> P[i].second;
  Sort(P);
  rep(i,0,N){
    sum+=P[i].second;
    if(sum>=K){
      Out(P[i].first);
      break;
    }
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define list _list
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
using namespace std;
const int N=105;
short s[N][N],f[N][N][N][N],line[N][N],list[N][N];
int gc(){
  char ch=getchar();
  while(ch!='.'&&ch!='o'&&ch!='E') ch=getchar();
  if (ch=='.') return 0;
  if (ch=='o') return 1;
  return 2;
}
int main(){
  int n,m,t,x,y; cin>>n>>m;
  for (int i=1; i<=n; ++i)
    for (int j=1; j<=m; ++j){
      t=gc();
      if (t==2) x=i,y=j;
      if (t==1) s[i][j]=1;
    }
  for (int i=1; i<=n; ++i)
    for (int j=1; j<=m; ++j){
      line[i][j]=line[i][j-1]+s[i][j];
      list[i][j]=list[i-1][j]+s[i][j];
    }
  int ans=0,sum;
  for (int i=0; i<=n-x; ++i)
    for (int j=0; j<x; ++j)
      for (int k=0; k<=m-y; ++k)
	for (int l=0; l<y; ++l){
	  if (x+i+1<=n-j) sum=max(0,line[x+i+1][min(m-l,y+k)]-line[x+i+1][max(k,y-l-1)]); else sum=0;
	  f[i+1][j][k][l]=max(f[i+1][j][k][l],f[i][j][k][l]+sum);
	  if (x-j-1>i) sum=max(0,line[x-j-1][min(m-l,y+k)]-line[x-j-1][max(k,y-l-1)]); else sum=0;
	  f[i][j+1][k][l]=max(f[i][j+1][k][l],f[i][j][k][l]+sum);
	  if (y+k+1<=m-l) sum=max(0,list[min(n-j,x+i)][y+k+1]-list[max(i,x-j-1)][y+k+1]); else sum=0;
	  f[i][j][k+1][l]=max(f[i][j][k+1][l],f[i][j][k][l]+sum);
	  if (y-l-1>k) sum=max(0,list[min(n-j,x+i)][y-l-1]-list[max(i,x-j-1)][y-l-1]); else sum=0;
	  f[i][j][k][l+1]=max(f[i][j][k][l+1],f[i][j][k][l]+sum);
	  ans=max(ans,f[i][j][k][l]);
	}
  cout<<ans;
  return 0;
}


Measured memory_bytes: 207232
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i) 
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	/
	/
	/
	*/
	int a, b, x;
	cin >> a >> b >> x;
	if (x - a <= b && x >= a) cout << "YES";
	else cout << "NO";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi   = vector<int>;
using vll  = vector<ll>;
using vc   = vector<char>;
using vvll  = vector<vll>;
using vvi  = vector<vi>;
using vvc  = vector<vc>;
using vb   = vector<bool>;
using vvb  = vector<vb>;
using pii  = pair<int,int>;
using vpii = vector<pii>;


int main() {
    int N, M, K; cin >> N >> M >> K;
    vll A(N); for(int i = 0; i < N; i++) cin >> A.at(i);
    vll B(M); for(int i = 0; i < M; i++) cin >> B.at(i);

    vll A_time(N+1), B_time(M+1);
    int max_i=0,tmp_j=M;int ans = 0;
    for(int i = 0; i < N; i++){
        A_time.at(i+1) = A_time.at(i)+A.at(i);
        if (A_time.at(i+1) < K) max_i = i+1;
    }
    for(int j = 0; j < M; j++){
        B_time.at(j+1) = B_time.at(j)+B.at(j);
    }
    for (int i = 0; i <= N; i++) {
        if(A_time.at(i) > K) break;
        while(B_time.at(tmp_j)>K-A_time.at(i)) {
            tmp_j--;
        }
        ans = max(ans, i+tmp_j);
    }

    cout << ans << endl;
}

Measured memory_bytes: 9580
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
*/
//入力終了→Ctrl+D
import java.util.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n=sc.nextInt(),m=sc.nextInt(),c=sc.nextInt();
        int[] b=new int[m];
        int[][] a=new int[n][m];
        for (int i = 0; i < m; i++) {
            b[i]=sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                a[i][j]=sc.nextInt();
            }
        }
        int ans=0;
        for (int i = 0; i < n; i++) {
            int temp=c;
            for (int j = 0; j < m; j++) {
                temp+=a[i][j]*b[j];
            }
            if(temp>0)ans++;
        }
        out.println(ans);
    }
}

Measured memory_bytes: 24020
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
b = a[:]
bs = set(b)
f = a[-1]
for i in range(n):
    a[i] = min(a[i],f-a[i])
a.sort()
s = a[-1]
if s in bs:
    print(f,s)
    exit()
s = f - s
print(f,s)

Measured memory_bytes: 16348
MOD = 1000000007
L=input()
N=len(L)
dp=[[0,0] for i in range(N+1)]
dp[0][1]=1
for i in range(N):
    if L[i]=='1':
        dp[i+1][1]=dp[i][1]*2
        dp[i+1][1]%=MOD
        dp[i+1][0]=3*dp[i][0]+dp[i][1]
        dp[i+1][0]%=MOD
    if L[i]=='0':
        dp[i+1][1]=dp[i][1]
        dp[i+1][0]=3*dp[i][0]
        dp[i+1][0]%=MOD
print((dp[N][0]+dp[N][1])%MOD)

Measured memory_bytes: 19684
#include<stdio.h>
int main(void){
	int a,b,c;
	int count=0;
	int i;
	
	scanf("%d %d %d",&a,&b,&c);
	
	for(i=a;i<=b;i++)
	{
		if(c%i==0) count++;
	}
	
	printf("%d\n",count);
	
	return 0;
}

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

int main (){
  int N, S;
  cin >> N >> S;
  vector<string> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  for(int i=0; i<N; i++){
    cout << vec.at(i);
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;

int main(){
    int n;
    cin >> n;
    int h,g,ans=0,t=0;
    cin >> h;
    rep(i,n-1){
        cin >> g;
        if (g<=h) t++;
        else t=0;
        h=g;
        ans=max(ans,t);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
while True:
  n = int(input())
  if n == 0:
    break
  
  large = 0
  for _ in range(n):
    p, d1, d2 = map(int, input().split())
    if large < d1 + d2:
      large = d1 + d2
      number = p
      
  print(number, large)


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


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

    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;


    for(int i = 0 ; i < n ; i++){
        string temp;
        cin >> temp;

        if(temp == "AC"){
            ac++;
        }else if(temp == "WA"){
            wa++;
        }else if(temp == "TLE"){
            tle++;
        }else{
            re++;
        }
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e12 + 5, mod = 1e9 + 7;

int main(){
	ll rowN, colN; cin >> rowN >> colN;
        vector<string> grid(rowN);
        for(int rep = 0; rep < rowN; ++rep){
            cin >> grid[rep];
        }
        vector<vector<ll>> ways(rowN + 1, vector<ll>(colN + 1, 0));
        ways[1][1] = 1;
        for(ll row = 1; row <= rowN; ++row){
            for(ll col = 1; col <= colN; ++col){
            	if(grid[row - 1][col - 1] != '#'){
                   ways[row][col] = (ways[row][col] + ways[row - 1][col]) % mod;
                   ways[row][col] = (ways[row][col] + ways[row][col - 1]) % mod;
                }
            }
        }
        cout << ways[rowN][colN] << endl;
    	return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    cout << a * b << " " << a * 2 + b * 2 << endl;
}


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){

	int N, M;
	int Di, Pi;
	int P[11], sum;
	int cnt;

	while (1){

		cin >> N >> M;
		if (N == 0 && M == 0) break;

		for (int i = 0; i < 11; i++) P[i] = 0;
		sum = 0;
		cnt = 10;

		for (int i = 0; i < N; i++){
			cin >> Di >> Pi;
			P[Pi] += Di;
		}

		while (cnt != -1){
			if (P[cnt] >= 1 && M != 0) M--;
			else if(P[cnt]!=0) sum += cnt;
			if (P[cnt] >= 1) P[cnt]--;
			else cnt--;
		}
		cout << sum << endl;

	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long 
#define pb push_back
using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
	int n, ans = 0;
	cin >> n;
	if(n%1000 > 0)
		ans = 1000 - n%1000;
	else 
		ans = 0;
	cout << ans;
    return 0;
}



Measured memory_bytes: 3640
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

pair<int, int> p[SIZE];
vector<int> a, b;

pair<int, int> calc(int X) {
  return {a[X - 1], b[X - 1]};
}

int main() {
  int N;

  scanf("%d", &N);

  for (int i = 0; i < N; i++) {
    int A, B;
    scanf("%d%d", &A, &B);
    p[i] = {A, B};
    a.push_back(A);
    b.push_back(B);
  }

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

  if (N % 2 == 1) {
    auto r = calc((N + 1) / 2);
    debug(r);
    printf("%d\n", r.second - r.first + 1);
  } else {
    auto r1 = calc(N / 2);
    auto r2 = calc(N / 2 + 1);
    debug(r1, r2);
    printf("%d\n", (r1.second + r2.second) - (r1.first + r2.first) + 1);
  }

  return 0;
}

Measured memory_bytes: 6696
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n); for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
typedef pair<int, int> P;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  string S,T;cin>>S>>T;
  bool ok=true;
  rep(i,S.size()){
    if(S[i]!=T[i])ok=false;
    
  }
  if(S.size()+1!=T.size())ok=false;
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}


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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;

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;
}

int r;

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

  cin >> r;
  cout << 3 * r * r << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int k,m,n;
	scanf("%lld",&n);
	for(register int i=1;i<=9;i++)
		for(register int j=1;j<=9;j++)
			if(i*j==n){puts("Yes");return 0;}
	puts("No");
	return 0;
}

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

int main() {
  
  int N, ans = 0;
  cin >> N;
  
  vector<int> A(N), B(N), C(N);
  
  for(int i = 0; i < N; i++) {
    cin >> A.at(i) >> B.at(i);
  }
  
  for(int i = 0; i < N; i++) {
    if(A.at(i) == B.at(i)) C.at(i) = 1;
  }
  /*
  for(int i = 0; i < N; i++) {
   	cout << C.at(i); 
  }*/
    
  for(int i = 0; i < N-2; i++) {
    if(C.at(i) == 1 && C.at(i+1) == 1 && C.at(i+2)) ans =1;
  }

  if(ans == 1) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 3628
#YYMM, MMYY, AMBIGUOUS, NA
S = str(input())

s0 = int(S[0:2])
s1 = int(S[2:])

if s0>12 or s0==0:#YYMM or NA
    if s1>12 or s1==0:
        ans="NA"
    else:
        ans="YYMM"
elif s1>12 or s1==0:#MMYY
    ans="MMYY"
else:
    ans="AMBIGUOUS"
    
print(ans)

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

int main()
{
    string S;
    cin >> S;
    map<string, int> answer;
    answer["SUN"] = 7;
    answer["MON"] = 6;
    answer["TUE"] = 5;
    answer["WED"] = 4;
    answer["THU"] = 3;
    answer["FRI"] = 2;
    answer["SAT"] = 1;
    
    cout << answer[S] << endl;
    return 0;
}

Measured memory_bytes: 256
# 解説

def main():
    N = int(input())
    s = input()

    dp = [[0] * N for _ in range(N)]
    ans = 0
    for i in range(N - 1, -1, -1):
        for j in range(N - 1, -1, -1):
            if s[i] == s[j]:
                if i + 1 < N and j + 1 < N:
                    dp[i][j] = min(dp[i + 1][j + 1] + 1, j - i)
                    ans = max(ans, dp[i][j])
                else:
                    dp[i][j] = 1
            else:
                dp[i][j] = 0
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  vector<int> ls(N);
  rep(i, N) {
    cin >> ls[i];
  }

  int ans = MAX;
  queue<tuple<int, int, int, int, int>> q;
  q.push(make_tuple(-1, 0, 0, 0, 0));
  while(!q.empty()) {
    auto t = q.front();
    q.pop();
    int cursor = get<0>(t);
    if (cursor == N) continue;
    int a = get<1>(t);
    int b = get<2>(t);
    int c = get<3>(t);
    int mergeCnt = get<4>(t);
    if (a != 0 && b != 0 && c != 0) {
      int num = abs(a-A)+abs(b-B)+abs(c-C)+(mergeCnt*10);
      ans = min(ans, num);
    }
    int l = ls[cursor+1];
    q.push(make_tuple(cursor+1, a+l, b, c, a == 0 ? mergeCnt : mergeCnt+1));
    q.push(make_tuple(cursor+1, a, b+l, c, b == 0 ? mergeCnt : mergeCnt+1));
    q.push(make_tuple(cursor+1, a, b, c+l, c == 0 ? mergeCnt : mergeCnt+1));
    q.push(make_tuple(cursor+1, a, b, c, mergeCnt));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Sample
{
  class Sample
  {
    static void Main()
    {
      
      var p = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
      var k = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
      int count = 0;
      foreach(var i in k){
 		
        count += i;

      }
      
      if(count >= p[0]){
      Console.Write("Yes");
      }else{
            Console.Write("No");

      
      }
      
		}
	}
}



Measured memory_bytes: 18528
N,M=map(int,input().split())
Key=[0]*(N+1)
for i in range(M):
    L,R = map(int,input().split())
    Key[L-1] += 1
    Key[R] -= 1
for i in range(N):
    Key[i+1] += Key[i] # 累積和
print(Key.count(M))

Measured memory_bytes: 6900
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    vll b;
    rep(i, n) {
        ll sm = 0;
        for (int j = i; j < n; ++j) {
            sm += a[j];
            b.pb(sm);
        }
    }
    ll ans = 0;
    for (int i = 40; i >= 0; --i) {
        int cnt = 0;
        rep(j, sz(b)) {
            if (((ans | 1LL<<i) & b[j]) == (ans | 1LL<<i)) cnt++;
        }
        if (cnt >= k) ans |= (1LL<<i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6384
import javax.print.attribute.ResolutionSyntax;
import java.util.*;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        HashMap result = new HashMap();
        result.put("AC",0);
        result.put("WA",0);
        result.put("TLE",0);
        result.put("RE",0);
        int n = sc.nextInt();
        for(int i= 0; i<n;i++){
            String s = sc.next();
            int tmp = (int) result.get(s);
            tmp++;
            result.put(s,tmp);
        }
        System.out.println("AC"+ " "+ "x" + " "+ result.get("AC") );
        System.out.println("WA"+ " "+ "x" + " "+ result.get("WA") );
        System.out.println("TLE"+ " "+ "x" + " "+ result.get("TLE") );
        System.out.println("RE"+ " "+ "x" + " "+ result.get("RE") );

    }


}


Measured memory_bytes: 49192
//#pragma GCC optimize(2)
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)
#define rrep(i, beg, end) for (int i = (beg); i >= (end); i--)
#define sp(i) setprecision(i) << fixed
typedef long long ll;
typedef pair<ll, ll> P;
typedef unsigned long long ull;
const int INF = 2e9;
const int mod = 1e9 + 7;
const int N = 1010;
ull p_hash(ull x, ull y) { return (x + y) * (x + y + 1) / 2 + y; } //NxN->N
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

deque<P> q;
char g[N][N];
int dis[N][N];
bool mark[N][N];
int h, w, ch, cw, dh, dw;

void dfs()
{
    memset(dis, 0x3f, sizeof dis);
    dis[ch][cw] = 0;
    q.push_back({ch, cw});
    int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
    while (!q.empty())
    {
        P t = q.front();
        q.pop_front();
        if (t.first == dh && t.second == dw)
            break;
        mark[t.first][t.second] = true;
        for (int i = 0; i < 4; i++)
        {
            int x = t.first + dx[i], y = t.second + dy[i];
            if (x >= 0 && x < h && y >= 0 && y < w && !mark[x][y] && g[x][y] == '.')
            {
                if (dis[t.first][t.second] < dis[x][y])
                {
                    dis[x][y] = dis[t.first][t.second];
                    q.push_front({x, y});
                }
            }
        }

        for (int x = t.first - 2; x <= t.first + 2; x++)
        {
            for (int y = t.second - 2; y <= t.second + 2; y++)
            {
                bool flag = false;
                if (x == t.first && y == t.second)
                    continue;
                for (int i = 0; i < 4; i++)
                {
                    int xx = t.first + dx[i], yy = t.second + dy[i];
                    if (x == xx && y == yy)
                        flag = true;
                }

                if (flag)
                    continue;

                if (x >= 0 && x < h && y >= 0 && y < w && !mark[x][y] && g[x][y] == '.')
                {
                    if (dis[t.first][t.second] + 1 < dis[x][y])
                    {
                        dis[x][y] = dis[t.first][t.second] + 1;
                        q.push_back({x, y});
                    }
                }
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> h >> w;
    cin >> ch >> cw;
    ch--, cw--;
    cin >> dh >> dw;
    dh--, dw--;
    rep(i, 0, h)
    {
        string s;
        cin >> s;
        rep(j, 0, w)
            g[i][j] = s[j];
    }

    dfs();
    if (dis[dh][dw] == 0x3f3f3f3f)
        cout << -1 << endl;
    else
        cout << dis[dh][dw] << endl;

    return 0;
}

Measured memory_bytes: 9768
N_MAX = 10**6
MOD = 10**9 + 7
fac, finv, inv = [0]*N_MAX ,[0]*N_MAX, [0]*N_MAX
def com_init():
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, N_MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

def com(n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


n,k = map(int, input().split())
r = n-k
com_init()

for i in range(1,k+1):
    ans = 0
    bi = com(k+i-1 -i, i-1)
    if i == 1:
        if r == 0: ri_m1 = 1
        else: ri_m1 = 0
    else:
        ri_m1 = com(r+i-2 -(i-1), i-2)
    ri = com(r+i-1 -i, i-1) if r >= i else 0
    ri_p1 = com(r+i -(i+1), i) if r >= i+1 else 0
    ans += bi*ri_m1
    ans += bi*ri*2
    ans += bi*ri_p1
    ans%=MOD
    print(ans)

Measured memory_bytes: 97700
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string.h>
#include<algorithm>
int a[1000000];
int main() {

	int s, tmp;
	

	scanf("%d", &s);
	a[0] = s;

	for (int i = 1; i < 1000000; i++) {
		if(a[i - 1] % 2 == 0) a[i] = a[i - 1] / 2;
		else if (a[i - 1] % 2 == 1)a[i] = a[i - 1] * 3 + 1;
		
		for (int j = 0; j < i; j++) {
			if (a[j] == a[i]) {
				tmp = i + 1;
				goto A;
			}
		}
	}
	A:
	printf("%d\n", tmp);


	return(0);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner stdin = new Scanner(System.in);
        
        int h;
        int w;
        
        while(true){
            h = stdin.nextInt();
            w = stdin.nextInt();
            if(h == 0 && w == 0)break;
            if(h <= 300 && w <= 300){
                for(int i = 0; i < h; i++){
                    for(int j = 0; j < w; j++){
                        System.out.print("#");
                    }
                    System.out.println();
                }
                System.out.println();
            }
        }
    }
}

Measured memory_bytes: 35008
S = list(input())
flag = True
if "N" in S:
  if "S" not in S:
    flag = False
if "S" in S:
  if "N" not in S:
    flag = False
if "E" in S:
  if "W" not in S:
    flag = False
if "W" in S:
  if "E" not in S:
    flag = False
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 61848
#include<bits/stdc++.h>
#define MAX 100001
using namespace std;

int head=0,tail=0;
struct Pss{
	char name[11];int time;
} Q[MAX];

void enq(Pss x){
	Q[tail] = x;
	tail = (tail+1)%MAX;
}
Pss deq(){
	Pss x = Q[head];
	head = (head+1)%MAX;
	return x;
}

int main(){
	int n,q,ssum=0;
	scanf("%d %d",&n,&q);
	for(int i=0;i<n;i++)
		scanf("%s %d",Q[i].name,&Q[i].time);
	tail = n;
	while(head!=tail){
		Pss t = deq();
		if(t.time<=q){
			ssum += t.time;
			printf("%s %d\n",t.name,ssum);
		}
		else{
			ssum += q;
			t.time -= q;
			enq(t);
		}
	}
	return 0;
}


Measured memory_bytes: 4688
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int64_t N, K, Q;
    cin >> N >> K >> Q;
    map<int, int>d;
    for (int64_t i=0; i<Q; i++) {
        int64_t A;
        cin >> A;
        if (d.count(A) > 0) {
            d[A] = d[A] + 1;
        } else {
            d[A] = 1;
        }
    }
    int64_t score = K - Q;
    for (int64_t i=0; i < N; i++) {
        if (d.count(i+1) > 0) {
            if (score + d[i+1] > 0) {
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else {
            if (score > 0) {
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 6492
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <numeric>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<long> A(N);

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

    long ans = 0;

    for(int i = 0; i < N; i++){
        while(A[i] % 2 == 0){
            A[i] = A[i] / 2;
            ans = ans + 1;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
// https://leetcode.com/problems/count-complete-tree-nodes/
#include <bits/stdc++.h>
using namespace std;


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

	
	int a, b, c; 
	cin >> a >> b >> c;

	if (a * b < c) {
		cout << (a * b);
	 } else {
		 cout << c;
	 }



    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  string s[n],t="";
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  for(int i=0;i<s[0].size();i++){
    char c=s[0][i];
    bool f=true;
    for(int j=1;j<n;j++){
      bool ff=true;
      for(int k=0;k<s[j].size();k++){
        if(c==s[j][k]){
          ff=false;
          break;
        }
      }
      if(ff){
        f=false;
        break;
      }
    }
    if(f){
      for(int j=1;j<n;j++){
        for(int k=0;k<s[j].size();k++){
          if(c==s[j][k]){
            s[j][k]='#';
            break;
          }
        }
      }
      t.push_back(c);
    }
  }
  sort(t.begin(),t.end());
  cout<<t;
}

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

int main() {
  string s,t;
  int ans=0;

  cin >> s >>t;

  for(int i=0;i<s.length();i++) {
    if(s[i]!=t[i]) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3848
#include <iostream>
using namespace std;
int main(){
   string days[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
   string S;
   int num;
   cin >> S;
   for(int i = 0; i < 7; i++) {
        if(S == days[i])
            num = 7 - i;
   }
   cout << num;
        return 0;
}


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

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

const int N = 100010;
vector<P> G[N];
vector<bool> seen(N);
vector<int> D(N, 0);

int n, m;

bool dfs(int now) {
  seen[now] = true;
  rep(i, G[now].size()) {
    P p = G[now][i];
    int to = p.first;
    int cost = p.second;

    if (seen[to]) {
      if (D[to] != D[now] + cost) return false;
    } else {
      D[to] = D[now] + cost;
      if (!dfs(to)) return false;
    }
  }
  return true;
}

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

  cin >> n >> m;
  rep(i, m) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    G[l].push_back(P(r, d));
    G[r].push_back(P(l, -d));
  }

  rep(i, n) {
    if (!seen[i]) {
      if (!dfs(i)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 12032
#include<iostream>
using namespace std;
int main()
{
    char a[50];
    cin.getline(a,50,'\n');
    for(int i=0;i<50;i++)
    {
        if(a[i]=='9')
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
	int a,b,c;
	cin>>a>>b>>c;
	int m = b > a ? b : a;
	int cnt = 0, ans = 0;
	while(cnt < c){
		cnt += m;
		ans++;
	}
	cout<<ans;
	return 0;
}

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

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
typedef long long ll;

int main(){
    ll A,B,C,K,max = 1e18;
    cin >> A >> B >> C >> K;
    K%=2;
    K = (ll) pow(-1,K);
    if ((A-B)*K > max) cout << "Unfair" << endl;
    else cout << (A-B)*K << endl;
}

Measured memory_bytes: 384
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.T = function(T) local t={} for i=1,T do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
----
local function factorial(n)
    local a = 1
    for i=1, n do
        a = a * i
    end
    return a
end

local function nCr(n, r)
    if r > n then
        return 0
    end
    if r > n/2 then
        r = n - r
    end
    local a = 1
    for i=n, n-r+1, -1 do
        a = a * i
    end
    return a // factorial(r)
end

local function normal(d, k)
    return nCr(d, k) * math.floor(9^k)
end
-- E
local S = read.l():totable()
local T = {}
for i=1,#S do
    T[i] = tonumber(S[i])
end
local D = #T
local K = read.n()

local function rec(x, remain)
    if remain == 0 then
        return 1
    end
    for i=x, D do
        if T[i] ~= 0 then
            local ans1 = normal(D-i, remain)
            local ans2 = (T[i] - 1) * normal(D-i, remain-1)
            local ans3 = 1 * rec(i+1, remain-1)
            return ans1+ans2+ans3
        end
    end
    return 0
end

local ans = rec(1, K)
print(ans)

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

int main()
{
    string N;
    cin >> N;
    if(N[0] == '7' || N[1] == '7' || N[2] == '7')cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <math.h>

int main(void)
{
	int a[4], b[4];
	int i, j, eat, bite;
	
	while (scanf("%d %d %d %d %d %d %d %d",
		&a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF){
		
		eat = 0;
		bite = 0;
		
		for (i = 0; i < 4; i++){
			for (j = 0; j < 4; j++){
				if (i == j && a[i] == b[j]){
					eat++;
				}
				else if (a[i] == b[j]){
					bite++;
				}
				/*printf("%d %d\n", a[i], b[j]);
				printf("%d %d\n\n", eat, bite);*/
			}
		}
		
		printf("%d %d\n", eat, bite);
		
	}
	
	return (0);
}

Measured memory_bytes: 596
# frozen_string_literal: true

n = gets.to_i
s = gets.strip

count = 0

0.upto(n-2) do |i|
  (i+1).upto(n-1) do |j|
    k = 2 * j - i
    next if k >= n

    if s[i] != s[j] && s[i] != s[k] && s[j] != s[k]
      count += 1
    end
  end
end

r = 0
g = 0
b = 0

cr = 'R'
cg = 'G'
s.chars.each do |c|
  if c == cr
    r += 1
  elsif c == cg
    g += 1
  else
    b += 1
  end
end

puts r * g * b - count

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll K;
ll A[101010];
ll num[42];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) {
		cin>>A[i];
		FOR(j,41) if(A[i]&(1LL<<j)) num[j]++;
	}
	
	ll ma=-1;
	ll ret=0;
	FOR(i,41) ret+=num[i]<<i;
	ma=ret;
	
	ret=0;
	FOR(j,41) {
		if((K>>j)&1) ret+=(N-num[j])<<j;
		else ret+=num[j]<<j;
	}
	ma=max(ma,ret);
	
	FOR(i,41) if(K&(1LL<<i)) {
		ll ret=0;
		FOR(j,41) {
			if(j>i) {
				if((K>>j)&1) ret+=(N-num[j])<<j;
				else ret+=num[j]<<j;
			}
			if(j==i) ret+=num[j]<<j;
			if(j<i) ret+=max(N-num[j],num[j])<<j;
		}
		ma=max(ma,ret);
	}
	
	
	cout<<ma<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1024