akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
int main()
{
    char str[3];
    scanf(" %s", str);
    int i, count = 0;
    if (strcmp(str, "RRR") == 0)
        printf("3");
    else if (strcmp(str, "SSS") == 0)
        printf("0");
    else if (strcmp(str, "RRS") == 0)
        printf("2");
    else if (strcmp(str, "SRR") == 0)
        printf("2");
    else
        printf("1");
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    
    int ans = 0;
    for(int i = N-1; i >= 0; i--) {
        if(i%2 == (N-1)%2) {
        	ans += a.at(i);
        }else if(i%2 == (N-2)%2) {
        	ans -= a.at(i);
        }
    }
    cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<bitset<30>> vec(n);
    rep(i, n) {
        int a;
        cin >> a;
        vec[i] = a;
    }

    bitset<30> all = 0;
    for(auto x : vec) all = all ^ x;

    rep(i, n) {
        bitset<30> ans = all ^ vec[i];
        long int answer = ans.bitset<30>::to_ulong();
        cout << answer << " ";
    }

    cout << endl;
    
    return 0;
}


Measured memory_bytes: 4700
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)

using namespace std;
typedef vector<int> vi;

int n, t;
string s;
vi TIME;
vi csum;
/*FUNCs=================================================*/
void solve() {

    TIME.assign(24*3600, 0);
    csum.assign(24*3600+1, 0);
    rep(i,n) {
        cin >> s;
        t = stoi(s.substr(0, 2))*3600 + stoi(s.substr(3, 2))*60 + stoi(s.substr(6,2));
        TIME[t] += 1;
        cin >> s;
        t = stoi(s.substr(0, 2))*3600 + stoi(s.substr(3, 2))*60 + stoi(s.substr(6,2));
        TIME[t] -= 1;
    }
    rep(i, 24*3600) csum[i+1] += csum[i] + TIME[i];
    sort(csum.rbegin(), csum.rend());
    cout << csum[0] << '\n';
}

/*MAIN==================================================*/
signed main(){

    while(cin >> n && n!=0) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3556
import numpy as np
S = np.array([ord(i)-97 for i in input()], dtype=int)
T = np.array([ord(i)-97 for i in input()], dtype=int)
Ns = len(S)
Nt = len(T)
equal = np.equal.outer(S, T).astype(int)
 
dp = [np.zeros(Nt + 1, dtype=int)]
for i in range(Ns):
    x = dp[-1].copy()
    newDP = x.copy()
    newDP[1:] = np.maximum(x[:-1] + equal[i], newDP[1:])
    np.maximum.accumulate(newDP, out=newDP)
    dp.append(newDP)
 
 
ans = ""
i, j = Ns, Nt
while i > 0 and j > 0:
    if S[i-1] == T[j-1]:
        ans += chr(S[i-1]+97)
        i -= 1
        j -= 1
        continue
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    else:
        j -= 1
 
print(ans[::-1])

Measured memory_bytes: 153596
#include<stdio.h>
int main(void)
{
	char s[3];
	int i;
	int c = 0;

	
		scanf("%s", &s);
	for (i = 0;i<3;i++) {
		if (s[i] == '1') {
			c++;
		}
	}
	printf("%d", c);
	return 0;
}

Measured memory_bytes: 1728
def Eratosthenes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

n = int(input())
n2 = n

if n < 2:
    print(n)
    exit()

prime_factors = [] #素因数
for i in Eratosthenes(int(n ** 0.5)):
    if i**2 > n2:
        break
    while n2 % i == 0:
        prime_factors.append(i)
        n2 //= i
if n2 > 1:
    prime_factors.append(n2)

ans = [str(i) for i in prime_factors]
ans = " ".join(ans)
print("{}: {}".format(n, ans))


Measured memory_bytes: 5876
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        System.out.println(Math.min(n, m) + Math.min(h, w));
    }

}


Measured memory_bytes: 23764
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)
	if 2*k - 1 <= b - a {
		for i := 0; i < k; i++ {
			fmt.Println(a + i)
		}
		for i := k-1; i >= 0; i-- {
			fmt.Println(b - i)
		}
	} else {
		for i := 0; i < b-a+1; i++ {
			fmt.Println(a + i)
		}
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int N;
int main() {
	cin >> N;
	int ft = 0, fx = 0, fy = 0;
	bool can = true;
	for (int i = 1; i < N+1; ++i) {
		int t, x, y; cin >> t >> x >> y;
		
		if ((t-ft) % 2 != 0) {
			if (((x + y) - (fx+fy)) % 2 != 0 && t-ft >= x+y-fx-fy) {
				ft = t; fx = x; fy = y;
				continue;
			}
			else {
				can = false;
			}
		}
		else {
			if (((x + y) - (fx + fy)) % 2 == 0 && t - ft >= x + y - fx - fy) {
				ft = t; fx = x; fy = y;
				continue;
			}
			else {
				can = false;
			}
		}
			if (!can) break;
	}
		if (can) cout << "Yes" << endl;
		else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque




def main():
    k, t = map(int, input().split())
    data = list(map(int, input().split()))
    ans = 0
    ikeru = (k + 1) // 2
    for i in range(t):
        if data[i] > ikeru:
            if k % 2:
                ans += (data[i] - ikeru) * 2
            else:
                ans += (data[i] - ikeru) * 2 - 1
    print(ans)







if __name__ == '__main__':
    main()



Measured memory_bytes: 38508
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
//#define minn 999999999
//#define maxx 0
ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll modulo(ll a, ll b)
{
    ll r = a % b;
    return r < 0 ? r + b : r;
}
//ncr
ull ncr(ull n, ull r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    ull ans = 1;
    ull i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
class abc
{
    public:
    ll val;
    ll ind;
};
bool fun1(abc x,abc y)
{
    return x.val>y.val;
}
///////////////////////////////////////////////////////
///////////////////////////////////////////
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll fact[100000+2];
ll ncrfast(ll n, ll r, ll p)
{
   if (r==0)
      return 1;
    return (fact[n]* modInverse(fact[r], p) % p *
            modInverse(fact[n-r], p) % p) % p;
}
///////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll k,x;
    cin>>k>>x;
    k=k*500;
    if( k>=x )
    cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
    
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define PRINT(a)   cout << (a) << endl
#define RALL(v) rbegin(v), rend(v)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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 (b<a) { a=b; return 1; } return 0; }

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

  vi a(N);

  REP(i,N)cin >> a[i];

  int cnt=0;
  REP(i, K){
    vi s(N+1,0);
    REP(i,N){
      int l = max(i-a[i], 0);
      int r = min(i+a[i]+1, N);
      s[l]+=1;
      s[r]-=1;
    }
    a[0]=s[0];
    REP(i,N){
      s[i+1] = s[i] + s[i+1];
    }
    int mi = INF;
    REP(i,N){
      a[i] = s[i];
      chmin(mi, a[i]);
    }
    if(mi == N)break;
  }

  REP(i,N){
    cout << a[i] << (i==N-1 ? "\n" : " ");
  }
}



Measured memory_bytes: 4808
N, K = map(int, input().split())

lis = []
for n in range(K):
    d = int(input())
    lis.append(list(map(int, input().split())))

ans_lis = []
for v in lis:
    for sunuke_num in v:
        ans_lis.append(sunuke_num)

print(N-len(set(ans_lis)))

Measured memory_bytes: 9224
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int ar[n+5];
for(int i=0;i<n;i++){

cin>>ar[i];
}
int ans=1;
for(int i=1;i<n;i++){
if(ar[i]<=ar[i-1]){
//ar[i]=ar[i-1];
//cout<<i<<endl;
ans++;
}
ar[i]=min(ar[i],ar[i-1]);
}
cout<<ans<<endl;
}


Measured memory_bytes: 1024
import sys


input = sys.stdin.readline
n = int(input())
m_list = []
for _ in range(n):
    m_list.append(list(map(int, input().split())))

p_list = [m_list[0][0]]
for i in range(n):
    p_list.append(m_list[i][1])

m = [[10**9]*(n+1) for i in range(n+1)]

for i in range(1, n+1):
    m[i][i] = 0
for l in range(2, n+1):
    for i in range(1, n-l+2):
        j = i + l - 1
        for k in range(i, j):
            m[i][j] = min(m[i][j], m[i][k]+m[k+1][j]+p_list[i-1]*p_list[k]*p_list[j])

print(m[1][n])



Measured memory_bytes: 5720
#include<bits/stdc++.h>
using namespace std;
long long n,k,a,ak,h;
int main()
{
	cin>>n>>k>>a;h=a;
	for(int i=2;i<=n;i++)
	{
		cin>>ak;
		a=__gcd(a,ak);
		h=max(h,ak);
	}
	if(k%a==0&&k<=h)
	{
		cout<<"POSSIBLE"<<endl;
		return 0;
	}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, cnt=0, sum=0, a[100];
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]%2==0)
            cnt++;
    }
    for(int i=1;i<=n;i++){
        if(a[i]%2==0)
            {
                if(a[i]%3==0 || a[i]%5==0)
                    sum++;
            }
    }


    if(cnt==sum)
        cout<<"APPROVED";
    else
        cout<<"DENIED";
}



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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B ;
  R = C + D ;
  if (L > R){
    cout << "Left";
  }
  else if (R > L){
    cout << "Right";
  }
  else{
    cout << "Balanced";
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#define N 8
#define NFR -1
#define FR 1


int row[N], col[N], dpos[2*N-1], dneg[2*N-1];
bool S[N][N];

void initialize(){
  int i;
  for(i = 0; i < N; i++){
    row[i] = FR;
    col[i] = FR;
  }
  for(i = 0; i < 2*N-1; i++){
    dpos[i] = FR;
    dneg[i] = FR;
  }
}

void print(){
  int i, j;
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(S[i][j]){
        if(row[i] != j) return;
      }
    }
  }

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(row[i] != j)
      printf(".");
      else printf("Q");
    }
    printf("\n");
  }
}

void Qeen(int i){
  int j;
  if(i == N){
    print();
    return;
  }

  for(j = 0; j < N; j++){
    //{i, j }がクイーンの攻撃範囲にあるか調査する
    if(col[j] == NFR || dpos[i+j] == NFR || dneg[i-j+(N-1)] == NFR) continue;
    //{i, j}がクイーンの攻撃範囲に入っていなければクイーンの配置をする
    row[i] = j;
    col[j] = NFR;
    dpos[i+j] = NFR;
    dneg[i-j+(N-1)] = NFR;

    Qeen(i+1);
    row[i] = FR;
    col[j] = FR;
    dpos[i+j] = FR;
    dneg[i-j+(N-1)] = FR;
  }
}

int main(){
  int i, j, k, r, c;

  initialize();

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      S[i][j] = false;
    }
  }

  scanf("%d", &k);
  for(i = 0; i < k; i++){
    scanf("%d%d", &r, &c);
    S[r][c] = true;
  }
  Qeen(0);

  return 0;
}



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

const int MAXN = 16;
const int INF = 1<<28;
int N;
int T[MAXN];
int G[MAXN][MAXN];
int dp[1<<MAXN];

int main() {
  for(; cin >> N && N; ) {
    for(int i = 0; i < N; ++i) {
      cin >> T[i];
      for(int j = 0; j < N; ++j) {
        cin >> G[i][j];
      }
    }
    fill(dp, dp+(1<<MAXN), INF);
    dp[0] = 0;
    for(int i = 0; i < (1<<N); ++i) {
      for(int j = 0; j < N; ++j) {
        if(i >> j & 1) continue;
        int ni = i | (1 << j);
        dp[ni] = min(dp[ni], dp[i] + T[j]);
        for(int k = 0; k < N; ++k) {
          if(i >> k & 1) ; else continue;
          dp[ni] = min(dp[ni], dp[i] + G[j][k]);
        }
      }
    }
    cout << dp[(1<<N)-1] << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F first
#define S second
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define sz size()
#define all(A)    A.begin(), A.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define f0(i,b)   for(int i=0;i<(b);i++)
#define f1(i,b)   for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define mod 1000000007

#define forr(i,n)    for(i=0; i<n; i++)
#define whilee(i,t)  while(i!=t)
#define  sl(a)  scanf("%lld",&a)
#define  pl(a)  printf("%lld\n",a)

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);
//scanf("%d",&x);
//printf("%d\n",x);

//vector <int> A;
//deque <int> A;
//queue <int> A;
//stack <int> A;
//set <int> A;
//map <int,int> A;
//pair <int,int> A ;
//vector <pair <int,int>> A ;
//bitset<32> bset1;
//char ch;
//string S, T, U;
ll i, j, k, a, b, c, d, f, g, h, l, m, n, p, q, r, s, t, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);//NULL
    cout.tie(nullptr);//NULL

    //scan(n);

    ll A[10];
    for(int i=0; i<5; i++)
    {
        cin>>A[i];
    }
    cin>>k;
    for(int i=4; i>0; i--)
    {
        for(int j=i-1; j>=0; j--)
        {
            if((A[i]-A[j])>k)
            {
                cnt=1;
                break;
            }
        }
    }
    cout << (cnt ? ":(" : "Yay!") << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func sum(n []int) int {
	a := 0
	for _, v := range n {
		a += v
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	n := getInt()

	a := make([]int, n)

	for i := range a {
		a[i] = getInt() - 1
	}
	fmt.Println(sum(a))
}


Measured memory_bytes: 640
N,M,X = map(int,input().split())
S=[0]*M
C=[]
ans=0

for i in range(N):
    A=list(map(int,input().split()))
    C.append(A)
    ans+=A[0]
    for j in range(M):
        S[j]+=A[j+1]

if min(S)<X:
    print(-1)
    exit()

for b in range(2**N):
    p=0
    S=[0]*M
    for i in range(N):
        if ( b >> i )&1:
            for j in range(M):
                S[j]+=C[i][j+1]
            p+=C[i][0]
    if min(S)>=X and p<ans:
        ans=p

print(ans)

Measured memory_bytes: 9244
N = int(input())
Rests = [input().split() for l in range(N)]
sorted_rests = sorted(Rests, key=lambda x:(int(x[1])), reverse=True)
sorted_rests = sorted(sorted_rests, key=lambda x:(x[0]), reverse=False)
for i in sorted_rests:
    print(Rests.index(i) + 1)


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
    char s[4];
    int ans = 7;
    scanf("%s", s);
    if(s[0] == 'o') ans++;
    if(s[1] == 'o') ans++;
    if(s[2] == 'o') ans++;
    printf("%d\n", (ans * 100));
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k, a[100010], mi = 2, ma = 3;
	cin >> k;
	for (int i = 1; i <= k; i++)cin >> a[i];
	if (a[k] != 2)cout << -1 << endl;
	else {
		for (int i = k - 1; i > 0; i--) {
			if (ma < a[i]) {
				cout << -1 << endl;
				return 0;
			}
			else ma = ma / a[i] * a[i] + a[i] - 1;
			if (mi <= a[i])mi = a[i];
			else mi = (mi + a[i] - 1) / a[i] * a[i];
			if (mi > ma) {
				cout << -1 << endl;
				return 0;
			}
		}
		cout << mi << " " << ma << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
int A, B, C ;

cin >> A>> B>>C ;
if ((A==5&& B==5 &&C==7  ) ||(A==5 && B==7&& C==5) ||(A==7 && B==5&& C==5))
   cout << "YES" <<endl;
else
    cout << "NO" <<endl ;


    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <complex>
#include <vector>
#define X real()
#define Y imag()
#define EPS (1e-10)
using namespace std;
typedef complex<double> P;
typedef pair<P, double> C;

namespace std{
  bool operator<(const P& a, const P& b){
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

P n_vector(P a){
  double l = abs(a);
  return P(-a.Y,a.X)/l;
}

vector<P> cpcc(C a, C b){
  double d = abs(a.first-b.first), ra = a.second, rb = b.second;
  double t = (ra*ra-rb*rb+d*d)/2/d, h = sqrt(ra*ra-t*t);
  P m = t/abs(b.first-a.first)*(b.first-a.first)+a.first;
  vector<P> cp(2,m);
  P n = n_vector(a.first-b.first);
  cp[0] -= h*n;
  cp[1] += h*n;
  return cp;
}


int main(){
  int N;
  double x, y;
  while(cin >> N, N){
    P ps[N];
    for(int i = 0; i < N; ++i){
      cin >> x >> y;
      ps[i] = P(x,y);
    }
    vector<P> cps;
    for(int i = 0; i < N; ++i){
      for(int j = i+1; j < N; ++j){
	if(abs(ps[i]-ps[j]) <= 2 + EPS){
	  vector<P> cp = cpcc(C(ps[i],1),C(ps[j],1));
	  for(int k = 0; k < cp.size(); ++k)
	    cps.push_back(cp[k]);
	}
      }
    }
    int n = cps.size(), ans = 1;
    for(int i = 0; i < n; ++i){
      int cnt = 0;
      for(int j = 0; j < N; ++j){
	if(norm(cps[i]-ps[j]) <= 1 + EPS)
	  ++cnt;
      }
      ans = max(ans, cnt);
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    cout << (n % 2 == 0 && s.substr(0, n/2) == s.substr(n/2, n/2) ? "Yes" : "No") << endl;
}


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

using namespace std;

int k;
string s;

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	
	cin >> k >> s;
	if (s.size() <= k) cout << s << '\n';
	else cout << s.substr(0, k) + "...\n";
	
	return 0;
}

Measured memory_bytes: 3528
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>

typedef long long ll;
using namespace std;
const int mod = 1000000007;

int main() {

    string S; cin >> S;

    int l = 1;
    int ind_R = 0, ind_L = 0;
    int cnt = 0;
    int lenS = S.size();
    lenS++;
    S.push_back('R');
    vector<int> ans(lenS);

    for (int i = 0; i < lenS; i++) {
        // cout << "=== : " << i << " : ===" << '\n';
        if (l && S[i] == 'L') {
                cnt++;
                ind_L = i;
                int tmp = ind_L - ind_R;
                ans[ind_L] += int(tmp / 2);
                ans[ind_L - 1] += (tmp+1) / 2;

                /*
                cout << "Now RRR... L \n";
                cout << "ind_R : " << ind_R << '\n';
                cout << ind_L << ' ' <<  (tmp+1) / 2 << '\n';
                cout << ind_L - 1 << ' ' <<  int(tmp / 2) << '\n';
                */

                l = 0;
                ind_R = ind_L - 1;
        }
        if (!l && S[i] == 'R') {
                ind_L = i - 1;
                int tmp = ind_L - ind_R;
                ans[ind_R] += int(tmp / 2);
                ans[ind_R + 1] += (tmp+1) / 2;

                /*
                cout << "Now RLLL... R \n";
                cout << "ind_R : " << ind_R << '\n';
                cout << ind_R << ' ' <<  int(tmp / 2) << '\n';
                cout << ind_R + 1 << ' ' <<  (tmp+1) / 2 << '\n';
                */

                l = 1;
                ind_R = ind_L + 1;
        }

        /*
        for (int i = 0; i < lenS - 1; i++) {
            cout << ans[i] << ' ';
        } cout << '\n';
        */
    }

    for (int i = 0; i < lenS - 1; i++) {
        cout << ans[i] << ' ';
    } cout << '\n';

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "0" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;
    ll ans=INF2;
    rep(i,4){
        ll x=N,y=M;
        ll buf=0;
        if(i&1) x*=-1,++buf;
        if(i&2) y*=-1,++buf;
        if(y-x<0) continue;
        buf+=y-x;
        mini(ans,buf);
    }
    cout<< ans <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n, k = li()
a = list(li())
INF = 10**18

cum_raw = [0]*(n+1)
cum_max = [0]*(n+1)

for i in range(n):
    cum_raw[i+1] = cum_raw[i] + a[i]
    cum_max[i+1] = cum_max[i] + (0 if a[i] < 0 else a[i])

ans = -INF

for i in range(n-k+1):
    white_zone = (cum_max[i] - cum_max[0]) + (cum_max[n] - cum_max[i+k])
    black_zone = (cum_raw[i+k] - cum_raw[i])
    ans = max(ans, white_zone)
    ans = max(ans, white_zone + black_zone)

print(ans)

Measured memory_bytes: 16904
N, K = map(int, input().split())

DIVIDER = 1000000007

tab_sum = [0]
sum_tmp = 0
for i in range(N + 1):
    sum_tmp = (sum_tmp + i) % DIVIDER
    tab_sum.append(sum_tmp)

ans = 0
for cnt in range(K, N + 2):
    val_min = (tab_sum[cnt] - tab_sum[0]) % DIVIDER
    val_max = (tab_sum[-1] - tab_sum[-1 - cnt]) % DIVIDER
    #
    ans = (ans + (val_max - val_min + 1)) % DIVIDER

print(ans)

Measured memory_bytes: 16936
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

n=int(input())
m=n+1
a=list(map(int,input().split()))

# MOD combination
def cmb(n, r, mod=10**9+7):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 10**5+10
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ma=0
dic={}
for i in range(m):
    if not a[i] in dic:
        dic[a[i]]=i
    else:
        ma=i-dic[a[i]]-1

for k in range(1,m+1):
    if k==1:
        print(n)
        continue
    tmp=cmb(m,k)

    tmp-=cmb(m-2-ma,k-1)
    print(tmp%mod)

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

int main(){
    int N;
    cin >> N;
    int M=N;
    int sum=0;

    for (int i=0; i<8; i++){
        if(M>0){
            sum+=M%10;
            M/=10;
        }
    }

    if (N%sum==0) {cout << "Yes" << endl;}
    else {cout << "No" << endl;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int x,k;
    cin>>x>>k;
    int y[x];
    int c=0;
    for (int i=0;i<x;i++){
        cin>>y[i];
        if (y[i]>=k)
            c++;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 640
# Q1
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

X = I()

if X >= 30:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9184
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int d, g, tot = 0;
	cin >> d >> g;
	static int dp[11][1111];
	for (int i = 0; i < d; ++i) {
		int p, c;
		cin >> p >> c;
		for (int j = 0; j <= tot; ++j) {
			for (int k = 0; k < p; ++k) {
				dp[i + 1][j + k] = max(dp[i + 1][j + k], dp[i][j] + k * (i + 1) * 100);
			}
			dp[i + 1][j + p] = max(dp[i + 1][j + p], dp[i][j] + p * (i + 1) * 100 + c);
		}
		tot += p;
	}
	int ans = 1 << 30;
	for (int i = 0; i <= tot; ++i) {
		if (dp[d][i] >= g) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
//#include<cstring>
#include<cmath>
//#include<cstdio>
//#include<algorithm>
using namespace std;

char c1[101],c2[101],c3[101]; 

int main(){
	cin>>c1>>c2>>c3;
	cout<<c1[0]<<c2[0]<<c3[0]<<endl;
	return 0;
}  

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 100000000

int M[MAX][MAX], n;

void dijksta(){
    int color[MAX], d[MAX], p[MAX];
    int mincost;
    int i, u, v;

    for(i = 0; i < n; i++){
        color[i] = WHITE;
        d[i] = INF;
        p[i] = -1;
    }
    d[0] = 0;

    while(1){
        mincost = INF;
        for(i = 0; i < n; i++){
            if(color[i] != BLACK && d[i] < mincost){
                mincost = d[i];
                u = i;
            }
        }

        if(mincost == INF) break;
        color[u] = BLACK;

        for(v = 0; v < n; v++){
            if(color[v] != BLACK && M[u][v] != INF){
                if(d[u] + M[u][v] < d[v]){
                    d[v] = d[u] + M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }

    for(i = 0; i < n; i++){
        printf("%d %d\n",i, d[i]);
    }

}

int main(){
    int k, c, v, u;
    int i, j;

    scanf("%d",&n);

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

    for(i = 0; i < n; i++){
        scanf("%d %d",&u ,&k);
        for(j = 0; j < k; j++){
            scanf("%d %d",&v, &c);
            M[u][v] = c;
        }
    }
    dijksta();
    return 0;
}



Measured memory_bytes: 2080
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long cnt[] = new long[60];
        for(int i = 0; i < n; i++){
            long x = sc.nextLong();
            for(int j = 0; j < 60; j++){
                cnt[j] += (x >> j & 1);
            }
        }
        long mod = 1000000007;
        long ans = 0;
        for(int i = 0; i < 60; i++){
            long t = (1L << i) % mod;
            ans += cnt[i] * (n - cnt[i]) % mod * t % mod;
            ans %= mod;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 87788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		sc.close();

		StringBuffer sbA = new StringBuffer();
		StringBuffer sbB = new StringBuffer();
		for(int i = 0; i < b; i++) {
			String S = String.valueOf(a);
			sbA.append(S);
		}
		for(int i = 0; i < a; i++) {
			String S = String.valueOf(b);
			sbB.append(S);
		}
		String A = sbA.toString();
		String B = sbB.toString();
		if(a < b) {
			System.out.println(A);
		}else {
			System.out.println(B);
		}
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;

using ipair = pair<int, int>;

ll INF = 1e16+7;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}


int H, W;

bool check(vector<vector<char>> field){

  vector<int> dx = {0, 0, 1,-1};
  vector<int> dy = {1,-1, 0, 0};

  rep(h, H){
    rep(w, W){
      if(field[h][w] == '.') continue;

      bool ok = false;
      rep(i, 4){
        int nh = h + dy[i];
        int nw = w + dx[i];

        if(0 <= nh && nh < H && 0 <= nw && nw < W){
          if(field[nh][nw]=='#'){
            ok = true;
          }
        }
      }

      if(!ok){
        return false;
      }
    }
  }

  return true;
} 


int main(){
  cin >> H >> W;
  vector<vector<char>> field(H, vector<char>(W, '.'));

  rep(i, H){
    rep(j, W){
      cin >> field[i][j];
    }
  }

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

  return 0;
}


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

using ll = long long;
const int mod = 1e9 + 7;

const int nax = 2e5 + 5;
int height[nax];
int beauty[nax];
ll dp[nax];
const int MAX = 2e5;
int main()
{
    srand(time(NULL));
    int n;
    cin >> n;
    //n = MAX;

    int base = 1;
    while(base < n) {
        base *= 2;
    }
    vector<ll> tree(2*base);

    for(int i = 0; i < n; i++) {
        //height[i] = 1 + rand()%n;
        cin >> height[i];
        dp[i+1] = 0;
    }
    for(int i = 0; i < n; i++) {
        //beauty[i] = 1 + rand()%n;
        cin >> beauty[i];
    }

    for(int i = 0; i < n; i++) {
        dp[height[i]] = beauty[i];
        /*for(int h = 1; h < height[i]; h++) {
            dp[height[i]] = max(dp[height[i]], dp[h]+beauty[i]);
        }*/
        //find max from 1 to height[i]-1.
        int r = base+height[i]-2;
        ll maxval = 0;
        while(r >= 1) {
            if(r%2 == 0) {
                maxval = max(maxval, tree[r]);
                r--;
            }
            r /= 2;
        }
        //set dp[height[i]] to maxval.
        maxval = max(maxval+beauty[i], dp[height[i]]);
        int k = base+height[i]-1;
        tree[k] = maxval;
        while(k > 1) {
            tree[k/2] = max(tree[k/2], maxval);
            k /= 2;
        }
        dp[height[i]] = maxval;
    }

    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        ans = max(ans, dp[i]);
    }
    cout << ans << endl;
}


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

namespace Atc_0040
{
    class Program
    {
        static void Main(string[] args)
        {
            var St = Console.ReadLine();

            long a = long.Parse(St.Split(' ')[0]);
            long b = long.Parse(St.Split(' ')[1]);
            long c = long.Parse(St.Split(' ')[2]);
            long d = long.Parse(St.Split(' ')[3]);

            if (Math.Abs(a - c) <= d || (Math.Abs(a - b) <= d && Math.Abs(b - c) <= d))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27336
import scala.io.StdIn.readLine

object Main extends App {

  val Array(n, m, _) = readLine().split(" ").map { _.toInt }

  val xss = Array.fill(n) { readLine().split(" ").map { _.toDouble } }
  val yss = Array.fill(m) { readLine().split(" ").map { _.toDouble } }
  val zss = ikj(xss, yss)
  for {
    zs <- zss
    ans = zs.map { _.longValue }.mkString(" ")
  } {
    println(ans)
  }

  def ikj(a1: Array[Array[Double]], a2: Array[Array[Double]]): Array[Array[Double]] = {
    val row = a1.length
    val col = a2(0).length
    val res = Array.ofDim[Double](row, col)
    for {
      i <- 0 until row
      k <- a2.indices
      j <- 0 until col
    } {
      res(i)(j) += a1(i)(k) * a2(k)(j)
    }

    res
  }
}



Measured memory_bytes: 56620
sx,sy,tx,ty = map(int,input().split())
diff_x = tx-sx
diff_y = ty-sy
ans = ''
ans += 'U'*diff_y
ans += 'R'*diff_x
ans += 'D'*diff_y
ans += 'L'*diff_x
ans += 'L'
ans += 'U'*(diff_y+1)
ans += 'R'*(diff_x+1)
ans += 'D'
ans += 'R'
ans += 'D'*(diff_y+1)
ans += 'L'*(diff_x+1)
ans += 'U'

print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    string s; cin >> s;

    int cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '1') {
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

// 以下の問題
// https://atcoder.jp/contests/abc048/tasks/abc048_a

func main() {
	var s1, s2, s3 string
	fmt.Scan(&s1, &s2, &s3)

	fmt.Println(string(s1[0]) + string(s2[0]) + string(s3[0]))
}


Measured memory_bytes: 512
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

void solve(){  
	int n;
	cin>>n;
	int ans=0;
	int a[55];
	rep(i,0,n) cin>>a[i];
	rep(i,0,n){
		rep(j,i+1,n){
			ans+=a[i]*a[j];
		}
	}
	cout<<ans<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int N;
int res[10000+1];
int main(){
  int i;
  int x;
  int y;
  int z;
  int v;
  rd(N);
  for(x=1;x*x<=N;x++){
    for(y=1;x*x+y*y+x*y<=N;y++){
      for(z=1;;z++){
        v = x*x + y*y + z*z + x*y + y*z + z*x;
        if(v > N){
          break;
        }
        res[v]++;
      }
    }
  }
  for(i=(1);i<(N+1);i++){
    wt_L(res[i]);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// int N;
// int res[1d4+1];
// {
//   int x, y, z, v;
//   rd(N);
//   for(x=1;x*x<=N;x++){
//     for(y=1;x*x+y*y+x*y<=N;y++){
//       for(z=1;;z++){
//         v = x*x + y*y + z*z + x*y + y*z + z*x;
//         if(v > N) break;
//         res[v]++;
//       }
//     }
//   }
//   rep(i,1,N+1) wt(res[i]);
// }


Measured memory_bytes: 3532
#include <stdio.h>

int main(void) {
	int arr[5];
	int i,j;
	int temp;
	for(i=0;i<5;i++)scanf("%d",&arr[i]);
	for(i=4;i>0;i--) {
		for(j=0;j<i;j++) {
			if(arr[j]<arr[j+1]) {
				temp=arr[j];
				arr[j]=arr[j+1];
				arr[j+1]=temp;
			}
		}
	}
	printf("%d %d %d %d %d\n",arr[0],arr[1],arr[2],arr[3],arr[4]);
	return 0;
}

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

int main()
{

    long long int n;
    cin>>n;
    string ans="";
    while(n)
    {
        long long int k=n/26;
        long long int z=n%26;
        if(z==0)
        {
            k--;
            ans=(char)('z')+ans;
        }
        else
        {
            ans=(char)('a'+z-1)+ans;
        }
        n=k;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3604
H, W = map(int, input().split())

MOD = 10**9 + 7
dp = [[0]*W for _ in range(H)]

for i in range(H):
  grid = input()
  if i == 0:
    Flag = True
    for j in range(W):
      if grid[j] == "#":
        Flag = False
      if Flag:
        dp[i][j] = 1
      else:
        dp[i][j] = 0
  else:
    for j in range(W):
      if grid[j] == "#":
        dp[i][j] = 0
      else:
        if j == 0:
          dp[i][j] = dp[i-1][j]
        else:
          dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD

print(dp[-1][-1])

Measured memory_bytes: 48356
*s,=map(int,input())
t=s[::-1]
n=len(s)
a=b=0
for i in range(1,n):
    a+=s[i]==s[i-1]
    s[i]=1-s[i-1]
for i in range(1,n):
    b+=t[i]==t[i-1]
    t[i]=1-t[i-1]
print(min(a,b))

Measured memory_bytes: 4640
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n;cin>>n;
    ll r=n%1000;
    ll ans;
    if(r==0){
        ans=0;
    }else{
        ans=1000-r;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3648
n=int(input())
a=[int(i) for i in input().split()]

import collections
 
c=collections.Counter(a)
l=c.most_common()

from operator import itemgetter

l.sort(key=itemgetter(0))   
l.reverse()

ans=[]
for i,j in l:
    if j>=4:
        ans.append(int(i))
        ans.append(int(i))
        break
    if j>=2:
        ans.append(int(i))
        if len(ans)==2:
            break

if len(ans)<2:
    ans.append(0)
    ans.append(0)
print(ans[0]*ans[1])

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

int main(){
int n,m,a[10000],b[10000];
int e=0;
cin>>n>>m;
int mx=m;
for(int i=0;i<n;i++){
cin>>a[i]>>b[i];
m+=a[i]-b[i];
if(m<0){e=1;}
mx=max(m,mx);
}

if(e==1){cout<<0<<endl;}
else{cout<<mx<<endl;}





return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
using ii=long long;
int main()
{
    int n;
    cin >> n;
    vector<int> v(n + 1);
    for (int &x : v) {
        cin >> x;
    }
    vector<int> d(n);
    for (int &x : d) {
        cin >> x;
    }
    ii res = 0;
    for (int i = n - 1; i >= 0; --i) {
        ii z = min(v[i + 1], d[i]);
        d[i] -= z;
        res += z;
        z = min(v[i], d[i]);
        res += z;
        d[i] -= z;
        v[i] -= z;
    }
    cout << res << "\n";
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

#define a first.first
#define b first.second
#define c second.first
#define d second.second


int N, M, Q;
vector<pair< pair<int,int>,pair<int,int>>> in;
int ans = 0;

void solve(vector<int> &A){
	
	if(A.size() == N + 1) {
		int sum = 0;
		// cout<<"<><>"<<endl;
		for(int i = 0; i < Q; i++){
			if(A[in[i].b] - A[in[i].a] == in[i].c) {
				sum += in[i].d;
			}
		}
		
		ans = max(sum, ans);
		
		return ;
	}
	
	for(int i = A.back(); i <= M; i++){
		A.push_back(i);
		solve(A);
		A.pop_back();
	}
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	vector<int> A;
	
	cin>>N>>M>>Q;
	
	in.resize(Q);
	
	for(int i = 0; i < Q; i++){
		cin>>in[i].a>>in[i].b>>in[i].c>>in[i].d;
	}
	
	A.push_back(1);
	
	solve(A);
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }

ll solve1(int n, int m, const vector<ll> & x, const vector<ll> & y, const vector<ll> & z) {
    vector<ll> a(n);
    REP (i, n) {
        a[i] = x[i] + y[i] + z[i];
    }
    sort(ALL(a));
    reverse(ALL(a));
    return accumulate(a.begin(), a.begin() + m, 0ll);
}

ll solve(int n, int m, vector<ll> & x, vector<ll> & y, vector<ll> & z) {
    ll ans = LLONG_MIN;
    REP (p, 2) {
        REP (q, 2) {
            REP (r, 2) {
                chmax(ans, solve1(n, m, x, y, z));
                transform(ALL(z), z.begin(), negate<ll>());
            }
            transform(ALL(y), y.begin(), negate<ll>());
        }
        transform(ALL(x), x.begin(), negate<ll>());
    }
    return ans;
}

int main() {
    int n, m; cin >> n >> m;
    vector<ll> x(n), y(n), z(n);
    REP (i, n) {
        cin >> x[i] >> y[i] >> z[i];
    }
    cout << solve(n, m, x, y, z) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N;
  cin >> N;

  ll ans = N / 11;
  ans *= 2;
  ll amari = N % 11;
  if (amari == 0) {
    RETURN(ans);
  }
  if (amari <= 6) {
    ans++;
  } else if (amari <= 11) {
    ans += 2;
  }
  ANS;
  return 0;
}

Measured memory_bytes: 3660
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int n,m;
map<int,int> factor;


signed main(){
    I(n); I(m);
    vi divisor;
    for (int i=1; i*i<=m; i++){
        if (m%i == 0){
            if (m/i >= n) divisor.pb(i);
            if (i*i != m && i >= n) divisor.pb(m/i);
        } 
    }
    cout << *max_element(all(divisor)) << endl;

}

Measured memory_bytes: 256