akhauriyash/Code-Regression huggingface dataset:
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール

// 処理内容
int main() {
    
    ll k, n; cin >> k >> n;

    // vector<ll> ans; ans.reserve(n);
    // ll offset = solve(ans, k, n);

    if (k % 2 == 0) {
        cout << k/2 << endl;
        REP(i, n-1) cout << " " << k;
        cout << endl;
        return 0;
    }

    vector<ll> ans(n, k/2 + 1);
    ll offset = n / 2;
    
    REP(i, offset) {
        if (ans.back() > 1) {
            --ans.back();
            while (ans.size() < n) ans.push_back(k);
        } else {
            ans.pop_back();
        }
    }

    REP(i, ans.size()) {
        // if (ans[i] == 0) break;
        if (i) cout << " ";
        cout << ans[i];
    }
    cout << endl;
    
}

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

const double eps = 1e-9;

bool same(double a, double b) { return abs(a - b) < eps; }

struct P {
    double x, y;
    P() : x(0), y(0) {}
    P(double x, double y) : x(x), y(y) {}
    P operator + (P b) { return P(x + b.x, y + b.y); }
    P operator - (P b) { return P(x - b.x, y - b.y); }
    P operator * (double b) { return P(x * b, y * b); }
    P operator / (double b) { return P(x / b, y / b); }
    double operator * (P b) { return x * b.x + y * b.y; }
    double operator ^ (P b) { return x * b.y - y * b.x; }
    double abs() { return hypot(x, y); }
    P unit() { return *this / abs(); }
};

struct L{
    // ax + by + c = 0
    double a, b ,c, o;
    P pa, pb;
    L() : a(0), b(0), c(0), o(0), pa(), pb() {}
    L(P pa, P pb) : a(pa.y - pb.y), b(pb.x - pa.x), c(pa ^ pb), o(atan2(-a, b)), pa(pa), pb(pb) {}
    P project(P p) {
        return pa + (pb - pa).unit() * ((pb - pa) * (p - pa) / (pb - pa).abs());
    }
};

P intersect(L x, L y) {
    if (same(x.a * y.b, x.b * y.a)) throw;
    double z = -x.a * y.b + x.b * y.a;
    return P(-x.b * y.c + x.c * y.b, x.a * y.c - x.c * y.a) / z;
}

int main() {
    P p1; cin >> p1.x >> p1.y;
    P p2; cin >> p2.x >> p2.y;
    L l(p1, p2);
    int q; cin >> q; while (q--) {
        P p; cin >> p.x >> p.y;
        p = l.project(p);
        cout << fixed << setprecision(10) << p.x << " " << p.y << '\n';
    }
}



Measured memory_bytes: 3472
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<stdio.h>
using namespace std;

int main(){
    string s;
    cin >> s;
    int a=0,b=0,l=s.size();
    for(int i=0;i<l;i++){
        if(s[i]=='S'){a++;}
        else if(s[i]=='T'){
            if(a)a--;
            else b++;
        }
    }
    cout << a+b << endl;
    return 0;
}

Measured memory_bytes: 640
<?php
	fscanf(STDIN, "%d %d", $H, $W);

	$input = [];

	for ($i = 0; $i < $H; $i++){
		fscanf(STDIN, "%s", $input[]);
	}

	$output = [];

	// 行がオール「．」のチェック
	for ($i = 0; $i < $H; $i++){
		if (strpos($input[$i], "#") !== false)  $output[] = $input[$i];
	}

// 	var_dump(count($output));
	$output2 = [];

	// 列がオール「．」のチェック
	for($i = 0; $i < count($output); $i++){ // 行
 		for ($j = 0; $j < $W; $j++){ // 列固定
			$chkflg = false;
			for ($k = 0; $k < count($output); $k++){ // 行でループ
				if (substr($output[$k], $j, 1) === "#") $chkflg = true;
			}
			if ($chkflg) $output2[$i] .= substr($output[$i], $j, 1);
		}
	}


	for($i = 0; $i < count($output2); $i++){
		print $output2[$i]."\n";
	}
?>

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

int main() {
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N);
  for (long long i = 0; i < N; i++){
    cin >> A.at(i);
  }
  vector<long long> B(N), C(N);
  B = A;
  C = A;
  
  int times = 0;
  int place = 1;
  while( B.at(place - 1) != 0 ) {
    B.at(place - 1) = 0;
    place = A.at(place - 1);
    times++;
  }
  
  int times_again = 0;
  int place_again = place;
  while( C.at(place_again - 1) != 0){
    C.at(place_again - 1) = 0;
    place_again = A.at(place_again - 1);
    times_again++;
  }
  
  if (times < K){
    if((K - times) % times_again == 0){
      cout << place << endl;
    }

    else{
      for(int i = 0; i < (K - times) % times_again; i++){
          place = A.at(place - 1);
      }
      cout << place << endl;
    }
  }
  
  else{
    int p = 1;
    for(int i = 0; i < K; i++){
      p = A.at(p - 1);
    }
    cout << p << endl;
  }
  
}


    


Measured memory_bytes: 8012
if !ENV['RUBY_THREAD_VM_STACK_SIZE']
  require 'rubygems';RUBY=Gem.ruby
  exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},RUBY,$0) #100MB
end

V = 100_005 # 頂点の最大数
 
class Graph
  attr_accessor :to, :seen, :cnt
 
  def initialize
    @to = Array.new(V*2){ [] }
    @seen = Array.new(V*2, false)
    @cnt = Array.new(2,0)
  end

  def add(x,y)
    y += V
    to[x] << y
    to[y] << x
  end

  def count(i)
    cnt.fill(0)
    dfs(i)
    cnt.first * cnt.last
  end
 
  def dfs(v)
    return if seen[v]
    seen[v] = true
    cnt[v/V] += 1
    to[v].each do |nv|
      dfs(nv)
    end
  end
end

# init
n = gets.to_i
g = Graph.new
n.times do
  x,y = gets.split.map(&:to_i)
  g.add(x,y)
end

# main
ans = 0
(V*2).times do |i|
  ans += g.count(i)
end
ans -= n
puts ans

Measured memory_bytes: 147648
n,k=map(int,input().split())
s=input()
cnt=1
siten=s[0]
onezero=[0]
for i in range(n-1):
    if s[i]!=s[i+1]:
        onezero+=[cnt]
    cnt+=1

onezero+=[cnt]

x=len(onezero)

if siten=='1':
    onezero+=[onezero[-1]]*2
    t=int(x/2-1)
    if k>=t:
        print(n)
    else:
        ans=[0]
        for i in range(t-k+2):
            ans+=[onezero[2*(i+k)+1]-onezero[2*i]]
        print(max(ans))

else:
    onezero+=[onezero[-1]]
    t=int(x/2)
    if k>=t:
        print(n)
    else:
        ans=[onezero[2*k]]
        for i in range(t-k):
            ans+=[onezero[2*(i+k+1)]-onezero[2*i+1]]
        print(max(ans))

Measured memory_bytes: 8672
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < ll , ll >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 
const ll inf=1e18+1e17;
const ll mod =1e9+7;
using cd= complex < double > ;
//const ll mod = 998244353;
ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}
const ll N = 2e5+5;
ll arr[N];
void solve(){
	int n;
	cin>>n;
	for ( int i=0;i<n;i++)
		cin>>arr[i];
	sort( arr,arr+n);
	ll ans=arr[n-1];
	int j=n-2;
	for ( int i=n-3;i>=0;i--){
		ans+=arr[j];
		if ( (n-i)%2)
			continue;
		j--;
	}
	cout<<ans<<'\n';

}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif
	ll t=1;
	//cin>>t;
	for ( ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
    	solve();
    }
}


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

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

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if (a>b)
        printf("a > b\n");
    else if(a<b)
        printf("a < b\n");
    else
        printf("a == b\n");
    return 0;
}



Measured memory_bytes: 2044
def main():
  n, mods = 0, [1]+[0]*2019
  d = 1
  for i, j in enumerate(reversed(input())):
    # n = (n+int(j)*pow(10, i, 2019))%2019
    n = (n+int(j)*d)%2019
    d=d*10%2019
    mods[n] += 1
  print(sum([i*(i-1)//2 for i in mods]))
main()

Measured memory_bytes: 9300
#include<stdio.h>
int main()
{
	char a[200][200];
	int n,l,i,j,g,s;
	scanf("%d %d",&n,&l );
	for(i=0;i<n;i++)
	scanf("%s",&a[i]);
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			g=0;
			for(g=0;g<l;g++)
			{
				if(a[i][g]>a[j][g])
				{
					char b[200];
					for(s=0;s<l;s++)
					{
						b[s]=a[i][s];
						a[i][s]=a[j][s];
						a[j][s]=b[s];
							
					}
					break;
				}
				else if(a[i][g]==a[j][g]) continue;
				else break; 
			}
				
		}
		
	}
	for(i=0;i<n;i++)
	printf("%s",a[i]);
} 

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

#define     bit_1(a)       __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     u              unsigned
#define     pb             push_back
#define     pf             push_front
#define     mpr            make_pair
#define     ins            insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     vstr           vector<string>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))
#define     orderset1      tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define     orderset2      tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));
/// lcm(a,b)=a/gcd(a,b)*b (handle overflow)

bool sortinrev1(const pair<int,int>&a,const pair<int,int>&b)
{
    //return (a.first > b.first);
    if(a.first==b.first)return (a.second>b.second);
    else return (a.first > b.first);
}
bool sortinrev2(const pair<int,int>&a,const pair<int,int>&b)
{
    //return (a.first > b.first);
    if(a.first==b.first)return (a.second<b.second);
    else return (a.first > b.first);
}
int fx[]={1,-1,0,0};
int fy[]={0,0,1,-1};


int main()
{
    int n;
    cin>>n;
    if(n>=30)cout<<"Yes\n";
    else cout<<"No\n";
}



Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-9;

double calc(int r, int x, int y) {
	if (r <= abs(x)) return DBL_MAX;
	return y - sqrt((double)r * r - x * x);
}

int main() {
	for (;;) {
		int r, n; cin >> r >> n;
		if (r == 0) break;
		vector<int> y(40);
		while (n--) {
			int xl, xr, h; cin >> xl >> xr >> h;
			for (int x = xl; x < xr; x++)
				y[20 + x] = max(y[20 + x], h);
		}
		double mini = DBL_MAX;
		for (int x = -20; x < 20; x++) {
			mini = min(mini, calc(r, x, y[20 + x]));
			mini = min(mini, calc(r, x + 1, y[20 + x]));
		}
		printf("%.10f\n", mini + r);
	}
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define po pop_back
#define mp make_pair
#define fi first
#define se second
#define hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007  
using namespace std;
bool comp(ll a,ll b){if(a>b)return true;else return false;}
int isP(ll n){if(n==1)return 0;if(n==2 || n==3)return 1;for(ll i=2;i<=sqrt(n);i++){if(n%i==0)return 0;}return 1;}
ll power(ll a,ll b){if(b==0)return 1;if(b==1) return a;ll t=power(a,b/2);if(b%2==1) return t*t*a;else return t*t;}
ll powMOD(ll x,ll y){if(y==0)return 1;if(y==1)return x;ll t=powMOD(x,y/2);if(y%2==1)return t*t%MOD*x%MOD;else return t*t%MOD;}
bool cmp(pair<ll,ll> p1,pair<ll,ll> p2){if(p1.fi>p2.fi) return true;if(p1.fi==p2.fi && p1.se>p2.se) return true;return false;}
 
 
int main()
{
    hello;
    
    ll t; 
//    cin>>t;
	t=1;
	while(t--){
		string s,t;
		cin>>s>>t;
		ll n=s.size(),m=t.size();
		ll ans=LONG_LONG_MAX;
		for(ll i=0;i<=n-m;i++){
			ll cn=0;
			for(ll j=0;j<m;j++){
				if(s[i+j]!=t[j]) cn++;
			}
			ans=min(ans,cn);
		}
		cout<<ans<<"\n";
	}
    
    return 0;  
} 

Measured memory_bytes: 3688
n = int(input())
ans = 0
m = 0
if n==1:
    print(1)
else:
    for i in range(2,n+1,2):
        a = 0
        x = i
        while(True):
            if x%2!=0:
                break
            a+=1
            x = x//2
        if a>m:
            m=a
            ans=i
    print(ans)

Measured memory_bytes: 3060
N=int(input())
W=[]
for i in range(N):
    W.append(input())
A=[]
for i in range(1,N):
    for j in range(0,i):
        if W[i]!=W[j] and W[i][0]==W[i-1][len(W[i-1])-1]:
            A.append('Yes')
        else:
            A.append('No')
if 'No' in A:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 65208
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <climits>

using namespace std;

typedef long long ll;

int main(){
  int n; cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  int minCost= INT_MAX;
  for(int v=-100;v<=100;v++){
    int cost=0;
    for(int id=0;id<n;id++){
      cost = cost + (a[id]-v)*(a[id]-v);
    }
    minCost = min(minCost, cost);
  }
  cout << minCost << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws IOException {
        int N = in.nextInt();         // number of items
        int W = in.nextInt();         // capacity
        int[] weight = new int[N];    // weights
        int[] value = new int[N];     // values
        
        for(int i = 0; i < N; i++){
            weight[i] = in.nextInt();
            value[i] = in.nextInt();
        }

        long[] dp = new long[W + 1];
        // without repetition - each item can be taken only once
        for(int n = 0; n < N; n++){
            for(int w = W; w >= weight[n]; w--){
                dp[w] = Math.max(dp[w], dp[w - weight[n]] + value[n]);
            }
        }

        out.println(dp[W]);
        in.close();
        out.close();
    }
  
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}


Measured memory_bytes: 27068
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

int k, a, b;


main () {
	cin >> k >> a >> b;
	for (int i = a; i <= b; ++i)	
		if (i % k == 0) {
			cout << "OK";
			return 0;
		}

	cout << "NG";
}




Measured memory_bytes: 3636
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <map>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::map<intmax_t, int> m;
  m[0] = 1;
  intmax_t s=0;
  for (size_t i=0; i<N; ++i) {
    int a;
    scanf("%d", &a);
    ++m[s+=a];
  }

  intmax_t res=0;
  for (const auto &p: m) {
    intmax_t x=p.second;
    res += x*(x-1)/2;
  }
  printf("%jd\n", res);
}


Measured memory_bytes: 12672
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
#include<random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const int MOD=1e9+7;

int main(){

  int n, m, a[101];
  cin >> n >> m;
  int total = 0;
  rep(i, n){
    cin >> a[i];
    total += a[i];
  }
  int sel = 0;
  rep(i, n) if(total <= 4 * m * a[i]) sel++;
  if(m <= sel) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 384
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
# N, M = gets_i_list
# list = gets_i_list

n = gets_i
a_list = gets_i_list
q = gets_i

a_count_h = a_list.sort.tally

total = a_count_h.map do |k, v|
  k * v
end.sum

dpp a_count_h
dpp total

q.times do
  b, c = gets_i_list
  b_count = a_count_h[b].to_i
  c_count = a_count_h[c].to_i

  dpp b_count
  dpp b_count

  total = total + ((c - b) * b_count)

  a_count_h.delete(b)
  a_count_h[c] = c_count + b_count

  puts total
end

Measured memory_bytes: 29180
n=int(input())
s=input()
d=dict()
ans=1
for i in range(n):
  if s[i] not in d:
    d[s[i]]=1
  else:
    d[s[i]]+=1
ld=list(d.values())
for i in range(len(ld)):
  if ld[i]==1:
    ans*=2
  else:
    ans*=ld[i]+1
print((ans-1)%(10**9+7))

Measured memory_bytes: 3188
N = int(input())
S = [input() for i in range(N)]
ans = {'AC':0, 'WA': 0, 'TLE':0, 'RE': 0,}

for i in S:
    ans[i] += 1

for i, j in zip(ans.keys(), ans.values()):
    print(i + ' x ' + str(j))


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  ll A, B; scanf("%lld %lld", &A, &B);
  vector<ll> H(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &H[i]);
  }

  ll low = 0, high = INF + 5;
  while (high - low > 1) {
    ll mid = (high + low) / 2;
    ll cnt = 0;
    for (int i = 0; i < N; ++i) {
      ll val = H[i] - B * mid;
      if (val > 0) {
        cnt += (val + A - B - 1) / (A - B);
      }
    }
    if (cnt <= mid) { high = mid; }
    else { low = mid; }
  }
  ll ans = high;
  printf("%lld\n", ans);
  return 0;
}


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

int main()
{
    ll n;
    cin>>n;
    string res="";
    while(n>0)
    {
        n--;
        int rem=n%26;
        char ch= 'a'+rem;
        res= ch+res;
        n/=26;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define maxx 1010
#define maxn 10010

int C[maxn];

int main(){
	int n,ans=0;
	int A[maxx],B[maxx];
	bool V[maxx];
	cin>>n;
	for(int i =0;i<n;i++) {
		cin>>A[i];
		B[i]=A[i];
		V[i]=false;
	}
	sort(B,B+n);
	for(int i=0;i<n;i++) C[B[i]]=i;
	int x=*min_element(A,A+n);
	for(int i=0;i<n;i++){
		if(V[i]==true) continue;
		int s=0,minn=maxn,c_len=0;
		int cur=i;
		while(V[cur]==false){
			c_len++;
			s+=A[cur];
			minn=min(minn,A[cur]);
			V[cur]=true;
			cur=C[A[cur]];
		}
		ans+=min(s+(c_len-2)*minn,s+minn+(c_len+1)*x);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3164
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}


const int MAX = 5e5+5;

struct Data
{
    int l,r,idx;
};
int BLOCK_SIZE;
bool cmp(Data a,Data b)
{
    if(a.l/BLOCK_SIZE != b.l/BLOCK_SIZE)
        return a.l/BLOCK_SIZE < b.l/BLOCK_SIZE;
    else if((a.l/BLOCK_SIZE)&1)
        return a.r < b.r;
    return a.r > b.r;
}

Data Q[MAX];
int a[MAX] , ans[MAX] , mp[MAX];
int cnt;

void add(int x)
{
    if(!mp[x])
        cnt++;
    mp[x]++;
}
void del(int x)
{
    mp[x]--;
    if(!mp[x])
        cnt--;
}
void MO(int n,int q)
{
    BLOCK_SIZE = sqrt(n);

    sort(Q,Q+q,cmp);

    int st = 0 , en = -1;
    cnt = 0;

    for(int i=0;i<q;i++)
    {
        int l = Q[i].l-1 , r = Q[i].r-1 , idx = Q[i].idx;

        while(st > l)
        {
            st--;
            add(a[st]);
        }
        while(st < l)
        {
            del(a[st]);
            st++;
        }
        while(en < r)
        {
            en++;
            add(a[en]);

        }
        while(en > r)
        {
            del(a[en]);
            en--;
        }

        ans[idx] = cnt;
    }

    for(int i=0;i<q;i++)
       cout<<ans[i]<<"\n";
}
int main()
{
    int t,cas=1,q;

        int n;

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

        for(int i=0;i<q;i++)
        {
            cin>>Q[i].l>>Q[i].r;
            Q[i].idx = i;
        }

       // printf("Case %d:\n",cas++);
        MO(n,q);



}




Measured memory_bytes: 15488
#include <bits/stdc++.h>
int main(int argc, char** argv)
{
    using namespace std;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    for (auto s_ : { 'a','b','c' })
    {
        if (s.find(s_) == string::npos)
        {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define LSOne(i) (i&(-i))
#define rep(i,a,b) for(int(i)=(a);(i)<(b);i++)
#define rrep(i,a,b) for(int(i)=(a);(i)>(b);i--)
#define BUG(x) {cout<<#x<<" = "<<x<<endl;}
#define left(x) (x<<1)
#define right(x) ((x<<1) +1)
#define middle(s,e)(s+(e-s)/2)
#define size_tree(n) 2*(int)pow(2,ceil(log2(n)))
#define CL(A,I) (memset(A,I,sizeof(A)))
#define endl '\n'
#define PHAS(_n) (pbits[(_n)>>5] & (1u << ((_n) & 0x1f)))
#define PSET(_n) (pbits[(_n)>>5] |= (1u << ((_n) & 0x1f)))
//unsigned int pbits[200000000/32+1];

static const int INF = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const long double epsilon = 1e-15;
static const long double pi = acos((long double) -1);
using namespace std;
inline void init_io(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef long long ll;
const int MAX_N = 100001;

/*
struct data{
  string s;
  int p,i;
  data():s(""), p(0), i(0){};
  data(string s_, int p_, int i_) : s(s_),p(p_), i(i_){};
  bool operator < (data other) const {
	if(s==other.s)
		return p>other.p;
    return s < other.s;
  }
};
*/

int arr[3*MAX_N];

void rarr(int n){
        rep(i,0,n)
            cin>>arr[i];
}

int A[101],B[101];

int main()
{
        init_io();
        int n;
        cin>>n;
        rep(i,0,n){
            cin>>A[i];
            B[i]=A[i];
        }
        rep(i,1,n)
            A[i]+=A[i-1];
        for(int i=n-2;i>=0;i--)
            B[i]+=B[i+1];
        int mn = INT_MAX;
        rep(i,0,n-1)
            if(mn>abs(A[i]-B[i+1]))
                    mn = abs(A[i]-B[i+1]);
        cout<<mn<<endl;
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int x=1;
  if(a!=b){
  x++;
  if(b!=c&&a!=c){
  x++;
  }
  }
  else{
  if(a!=c){
  x++;
  }
  }
  cout<<x<<endl;
}


Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


typedef pair<int, int>P;
typedef pair<int, P>IP;

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

int H, W;
char mp[1010][1010];
int ans = 0;
int cnt = 0;
int main(){
    for(int i = 0; i < 1010; i++){
        for(int j = 0; j < 1010; j++){
            mp[i][j] = '@';
        }
    }
    cin >> H >> W;
    queue<IP>Q;
    for(int y = 1; y <= H; y++){
        for(int x = 1; x <= W; x++){
            cin >> mp[y][x];
            if(mp[y][x] == '#'){
                mp[y][x] = '.';
                Q.push(IP(0, P(x, y)));
            }
        }
    }
    while(cnt < H * W){
        while(!Q.empty()){
            int cost = Q.front().first;
            int x = Q.front().second.first;
            int y = Q.front().second.second;
            Q.pop();
            if(mp[y][x] == '#')continue;
            mp[y][x] = '#';
            cnt++;
            ans = cost;
            for(int i = 0; i < 4; i++){
                int xx = x + dx[i];
                int yy = y + dy[i];
                if(mp[yy][xx] == '.'){
                    Q.push(IP(cost + 1, P(xx, yy)));
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int search(const vector< vector<int> >& g, int p, int prev, int rest){
	if(rest == 0) return 1;
	int res = 1;
	for(int t : g[p]){
		if(t == prev) continue;
		int r = search(g, t, p, rest-1);
		res += r;
	}
	return res;
}

int center(const vector< vector<int> >& g, int s, int k){
	int maxDif = 0;
	int res = 1;
	for(int t : g[s]){
		int r = search(g, t, s, k/2-1);
		if(k%2 == 1){
			int r2 = search(g, t, s, k/2);
			maxDif = max(maxDif, r2 - r);
		}
		res += r;
	}
	return res + maxDif;
}

int main(){
	int N, K;
	while(cin >> N >> K){
		vector< vector<int> > g(N);
		for(int i=0;i<N-1;i++){
			int A, B;
			cin >> A >> B;
			--A; --B;
			g[A].push_back(B);
			g[B].push_back(A);
		}
		if(K == 1){
			cout << N-2 << endl;
		} else {
			int res = N;
			for(int i=0;i<N;i++) res = min(res, N-center(g, i, K));
			cout << res << endl;
		}
	}
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "D:\C++\test_lib_projects\testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)

bool debug=true;

/*    *************************************
	  * Written in New Computer           *
	  * The following code belongs to     *
	  * XiaoGeNintendo of HellHoleStudios *
	  *************************************
*/
template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
	os<<ptt.first<<","<<ptt.second;
	return os;
}
template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
	os<<"{";
	for(int i=0;i<vt.size();i++){
		os<<vt[i]<<" ";
	}
	os<<"}";
	return os;
}

int n;
int a[200005];
map<int,int> mp;
int p2[33];
int main(int argc,char* argv[]){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	
	p2[0]=1;
	for(int i=1;i<=30;i++){
		p2[i]=p2[i-1]*2;
	}
	
	sort(a,a+n);
	reverse(a,a+n);
	
	int ans=0;
	for(int i=0;i<n;i++){
		if(mp[a[i]]==0){
			continue;
		}
		for(int j=30;j>=1;j--){
			if(p2[j]<=a[i]){
				continue;
			}
			int ano=p2[j]-a[i];
			int left=mp[ano];
			if(left>=2 || left==1 && a[i]!=ano){
				mp[ano]--;
				mp[a[i]]--;
				ans++;
				break;
			}
		}
	}
	
	cout<<ans;
	return 0;
}



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

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }

    ll money = 1000;
    rep(i,n-1){
        if(a[i] < a[i+1]){
            money = money/a[i]*a[i+1] + (money % a[i]);
        }
    }
    cout << money << endl;
}

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

struct edge{
    int to,col,dist;
};

class LCA{
private:
	vector<vector<edge>> v;
	vector<vector<int>> parent;
	vector<int> depth;
	void dfs(int n,int m,int d){
		parent[0][n] = m;
		depth[n] = d;
		for(auto x:v[n]){
			if(x.to!=m) dfs(x.to,n,d+1);
		}
	}
public:
	LCA(int N,int root,vector<vector<edge>>& tree){
		v = tree;
		parent = vector<vector<int>>(21,vector<int>(N+1,0));
		depth = vector<int>(N+1,0);
		dfs(root,-1,0);
		for(int j=0;j+1<20;j++){
			for(int i=1;i<=N;i++){
				if(parent[j][i]<0) parent[j+1][i] = -1;
				else parent[j+1][i] = parent[j][parent[j][i]];
			}
		}
	}
	int lca(int n,int m){
		if(depth[n]>depth[m]) swap(n,m);
		for(int j=0;j<20;j++){
			if((depth[m]-depth[n]) >> j&1) m = parent[j][m];
		}
		if(n==m) return n;
		for(int j=19;j>=0;j--){
			if(parent[j][n]!=parent[j][m]){
				n = parent[j][n];
				m = parent[j][m];
			}
		}
		return parent[0][n];
	}
	int dep(int n){return depth[n];}
};

struct query{
    int col,value,id;
    bool is_lca;
};

struct color{
    int dist,num;
};

void dfs(int now,int par,int d,vector<vector<query>>& q,vector<vector<edge>>&tree,vector<int>& ans,map<int,color>& m){
    for(auto x:q[now]){
        int res;
        if(!m.count(x.col)) res = d;
        else res = d-m[x.col].dist+x.value*m[x.col].num;
        if(x.is_lca) ans[x.id] -= 2*res;
        else ans[x.id] += res;
    }
    for(auto x:tree[now]) if(x.to!=par){
        m[x.col].dist += x.dist;
        m[x.col].num++;
        dfs(x.to,now,d+x.dist,q,tree,ans,m);
        m[x.col].dist -= x.dist;
        m[x.col].num--;
    }
}
    

int main(){
    int N,Q;
    cin >> N >> Q;
    vector<vector<edge>> tree(N+1);
    for(int i=0;i<N-1;i++){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        tree[a].push_back({b,c,d});
        tree[b].push_back({a,c,d});
    }
    LCA lca(N,1,tree);
    vector<vector<query>> q(N+1);
    vector<int> ans(Q,0);
    for(int i=0;i<Q;i++){
        int x,y,u,v;
        cin >> x >> y >> u >> v;
        q[u].push_back({x,y,i,false});
        q[v].push_back({x,y,i,false});
        q[lca.lca(u,v)].push_back({x,y,i,true});
    }
    map<int,color> m;
    dfs(1,0,0,q,tree,ans,m);
    for(auto x:ans) cout << x << endl;
}

Measured memory_bytes: 44788
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

Int N;
Int ga,ba,sa;
Int gb,bb,sb;

Int solve(void) {
    vector<Int> dp(N+1,0);

    for(Int i = 0;i <= N;i++) {
        Int t = i;
        if(i >= ga) t = max(t,dp[i-ga]+gb);
        if(i >= ba) t = max(t,dp[i-ba]+bb);
        if(i >= sa) t = max(t,dp[i-sa]+sb);
        dp[i] = t;
    }

    vector<Int> ans(dp.back()+1,0);
    for(Int i = 0;i <= dp.back();i++) {
        Int t = i;
        if(i >= gb) t = max(t,ans[i-gb]+ga);
        if(i >= bb) t = max(t,ans[i-bb]+ba);
        if(i >= sb) t = max(t,ans[i-sb]+sa);
        ans[i] = t;
    }

    return ans.back();
}

int main(void) {
    cin>>N;
    cin>>ga>>ba>>sa;
    cin>>gb>>bb>>sb;
    cout<<solve()<<endl;

    return 0;
}



Measured memory_bytes: 195584
import sys
import math
import bisect
import numpy as np
input = sys.stdin.readline
MOD = 10**9 + 7
INF = float('INF')

def main():
    n = int(input())
    v = list(map(float,input().split()))
    v = np.array(v)
    v.sort()

    for i in range(n, 1, -1):
        v[:i] = v[:i] * 0.5

    ans = sum(v)
    print(ans)


if __name__ == '__main__':
    main()

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

// Contest: AtCoder Beginner Contest 152 (https://atcoder.jp/contests/abc152)
// Problem: D: Handstand 2 (https://atcoder.jp/contests/abc152/tasks/abc152_d)

using namespace std;

#define sz(x)       (int)size(x)
#define rep(a, b)   for(int a = 0; a < (b); ++a)
#define all(a)      (a).begin(),(a).end()
#define trav(a, b)  for(auto& a : b)

template <class T, size_t... Is> struct arr_helper;
template <class T, size_t... Is> using arr = typename arr_helper<T, Is...>::type;
template <class T> struct arr_helper<T> { using type = T; };
template <class T, size_t I, size_t... Is>
struct arr_helper<T, I, Is...> { using type = array<arr<T, Is...>, I>; };

using ll = long long;
using u64 = uint64_t;
using u32 = uint32_t;

using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pi>;

const int INF = (int)1e9;
const ll INFL = (ll)1e18;

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

    arr<int, 10, 10> cnt{};
    int n; cin >> n;
    ll res = 0;

    for (int i = 1; i <= n; ++i) {
        int last = i % 10;
        int first = i;
        while (first >= 10) first /= 10;
        res += 2 * cnt[last][first];
        res += (first == last);
        cnt[first][last]++;
    }

    cout << res << '\n';
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    set<int> x;
    for(int i=0;i<n;i++){
        int d;
        cin >> d;
        x.insert(d);
    }
    int ans = x.size();
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
  public static TreeMap<Long, Long> findPrimeFactors(long n) {
    TreeMap<Long, Long> res = new TreeMap<>();
    long m = n;
    for (long i = 2; i * i <= m; i++) {
      while (m % i == 0) {
        long val = 1 + res.getOrDefault(i, 0L);
        res.put(i, val);
        m /= i;
      }
    }
    if (m != 1) {
      long val = 1 + res.getOrDefault(m, 0L);
      res.put(m, val);
    }
    return res;
  }

  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    String[] ss = input.nextLine().split(" ");
    long a = Long.parseLong(ss[0]);
    long b = Long.parseLong(ss[1]);
    TreeMap<Long, Long> fa = findPrimeFactors(a);
    TreeMap<Long, Long> fb = findPrimeFactors(b);
    for (long p: fb.keySet()) {
      long val = fa.getOrDefault(p, 0L);
      fa.put(p, Long.max(fb.get(p), val));
    }
    long ans = 1;
    for (long p: fa.keySet()) {
      long temp = 1;
      for (int i = 0; i < fa.get(p); i++) {
        temp *= p;
      }
      ans *= temp;
    }
    System.out.println(ans);
  }
}


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

void output_vector(vector<int> &A) {
  int vector_size = A.size();
  
  for (int i = 0; i < vector_size-1; i++) {
    cout << A.at(i) << " ";
  }
  cout << A.at(vector_size-1) << endl;
}

int main() {
  int N, v, j;
  cin >> N;
  vector<int> A(N);

  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  int num_change = 0;
  bool flag = true;
  while (flag) {
    flag = false;
    for (int j = N-1; j >=1; j--) {
      if (A.at(j) < A.at(j-1)) {
        int tmpA = A.at(j);
        A.at(j) = A.at(j-1);
        A.at(j-1) = tmpA;
        num_change++;
        flag = true;
      }
    }
  }
  
  output_vector(A);
  cout << num_change << endl;
  
}


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

using namespace std;

char arr[1001][1001];
long long a[1002][1002];

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

	const long long mod = 1e9 + 7;
	long long h, w;
	cin >> h >> w;

	for(long long i = 0; i < h; i++){
		for(long long j = 0; j < w; j++){
			cin >> arr[i][j];
		}
	}

	a[0][0] = 1;
	for(long long i = 0; i < h; i++){
		for(long long j = 0; j < w; j++){
			if(!i && !j) continue;
			if(!i){
				if(arr[i][j] == '#' || a[i][j-1] == 0) 
					a[i][j] = 0;
				else 
					a[i][j] = 1;
			}
			else if(!j) {
				if(arr[i][j] == '#' || a[i-1][j] == 0) 
					a[i][j] = 0;
				else 
					a[i][j] = 1;
			}
			else{
				if(arr[i][j] == '.') a[i][j] = (a[i-1][j] + a[i][j-1])%mod;
				else a[i][j] = 0;
			}
		}
	}

	cout << a[h-1][w-1];

	return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

ll pow_mod(ll a,ll b){
  if(b==0){
    return 1;
  }
  else if(b%2==1){
    return (a*pow_mod(a,b-1))%MOD;
  }
  else{
    ll t=pow_mod(a,b/2);
    return t*t%MOD;
  }
}

vector<ll> memo(200001,MOD+1);
ll cnt_gcd(ll a,ll k,ll n){
  if(memo[a]!=MOD+1){
    return memo[a];
  }
  ll b=pow_mod((k/a),n);
  ll i=1;
  while(a+a*i<=k){
    b =(b-cnt_gcd(a+a*i,k,n))%MOD;
    i++;
  }
  memo[a]=b%MOD;
  return b%MOD;
}
  
int main() {
  ll n,k;
  cin >> n >> k;
  ll ans=0;
  for(ll i=k;i>=1;i--){
    ans=(ans+i*(cnt_gcd(i,k,n)))%MOD;
  }
  cout << (ans+MOD)%MOD << endl;
}


Measured memory_bytes: 4664
#include <stdio.h>
#include <stdlib.h>

int max(int a, int b);
int min(int a, int b);
int cmp(const void *p, const void *q);

int main(int argc, char const *argv[])
{
    int n;
    int h[100] = {0};
    int i;
    int j;
    int cnt = 0;

    scanf("%d", &n);

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

    i = 0;

    while(i != n) {
        if (h[i] != 0) {
            for (j = i; j < n; j++) {
                if (h[j] > 0) {
                    h[j]--;
                } else {
                    break;
                }
            }
            cnt++;
        } else {
            i++;
        }
    }

    printf("%d", cnt);

    return 0;
}

int max(int a, int b) {
    return a > b ? a : b;
}

int min(int a, int b) {
    return a < b ? a : b;
}

int cmp(const void *p, const void *q) {
    return -(*(int*)p - *(int*)q);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define f first
#define s second
#define inf 1<<30
using namespace std;

int n,m;
struct edge{ int to,dis,cost; };
vector<edge> V[10001];

void add_edge(int from,int to,int dis,int cost){
  V[from].push_back((edge){to,dis,cost});
  V[to].push_back((edge){from,dis,cost});
}

int Dijkstra()
{
  priority_queue<pair<int,int> > PQ;
  int d[10000],color[10000],c[10000];
  for(int i=0;i<n;i++){
    d[i]=inf;
    color[i]=0;
    c[i]=inf;
  }
  d[0]=0;
  PQ.push(make_pair(0,0));
  color[0]=0;
  while(!PQ.empty()){
    pair<int,int> p=PQ.top();PQ.pop();
    int u=p.s;
    color[u]=2;

    if(d[u]<p.f*(-1))continue;

    for(int i=0;i<V[u].size();i++){
      edge e=V[u][i];
      if(color[e.to]==2)continue;
      if(d[e.to]>d[u]+e.dis){
	d[e.to]=d[u]+e.dis;
	c[e.to]=e.cost;
	PQ.push(make_pair(d[e.to]*(-1),e.to));
	color[e.to]=1;
      }
      else if(d[e.to]==(d[u]+e.dis)){
	if(c[e.to]>e.cost){
	  d[e.to]=d[u]+e.dis;
	  c[e.to]=e.cost;
	  PQ.push(make_pair(d[e.to]*(-1),e.to));
	  color[e.to]=1;
	}
      }
    }
  }
  int ans=0;
  for(int i=1;i<n;i++)ans+=c[i];
  return ans;
}  

int main()
{
  int x,y,d,c;
  while(1){
    cin>>n>>m;
    if(n+m==0)break;
    for(int i=0;i<n;i++)V[i].clear();
    for(int i=0;i<m;i++){
      cin>>x>>y>>d>>c;
      x--;y--;
      add_edge(x,y,d,c);
    }
    cout<<Dijkstra()<<endl;
  }
  return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

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

double N;
V L;

int main() {
    cin >> N;
    L.resize(N);
    VECCIN(L);
    sort(All(L));
    int other = 0, M = L[N - 1];
    REP(i, N - 1) { other += L[i]; }
    Yes(other > M);
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const *argv[])
{
    unsigned int S = 0;

    std::cin >> S;

    unsigned int h = S / (60 * 60);
    unsigned int m = (S - h * (60 * 60)) / 60;
    unsigned int s = S % 60;

    std::cout << h << ":" << m << ":" << s << std::endl;

    return 0;
}

Measured memory_bytes: 3092
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
void CountingSort(int A[], int B[], int k,int n);
int main(){
	int *A, *B, k,n,i;
	scanf("%d", &n);
	A = (int *)malloc(sizeof(int)*n);
	for (i = 0; i < n; i++) {
		scanf("%d", A + i);
		if (i == 0) k = *(A + i);
		if (*(A + i) > k) k = *(A + i);
	}
	B = (int *)malloc(sizeof(int)*(k+n));
	CountingSort(A, B, k,n);
	for (i = 1; i < n+1; i++) printf("%d%c", *(B + i), i < n ? ' ' : '\n');
	free(A);
	free(B);
	return 0;
}

void CountingSort(int A[], int B[], int k,int n){
	int i,*C;
	C = (int *)malloc(sizeof(int)*(k+n));
	for (i = 0; i <= k; i++) C[i] = 0;
	for (i = 0; i < n; i++) C[A[i]]++;
	for (i = 1; i <= k; i++)C[i] += C[i - 1];

	
	for (i = n-1; i >= 0; --i) {
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}
	
	free(C);
}

Measured memory_bytes: 16188
//waz
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))
 
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;
 
#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))
 
int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int mod = 1e9 + 7;

int fpow(int a, int x)
{
	int ret = 1;
	for (; x; x >>= 1)
	{
		if (x & 1) ret = 1LL * ret * a % mod;
		a = 1LL * a * a % mod;
	}
	return ret;
}

int f[2010][2010], n, k, fac[2010 * 2010], ifac[2010 * 2010];

int C(int n, int m)
{
	if (n < m || m < 0) return 0;
	return 1LL * fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}

int get(int x, int y)
{
	return C(x + y, y);
}

int main()
{
	gii(n, k);
	if (k == 1)
	{
		puts("1");
		return 0;
	}
	f[0][0] = 1;
	fac[0] = 1;
	for (int i = 1; i <= (n + 2) * (k + 2); ++i) fac[i] = 1LL * fac[i - 1] * i % mod;
	ifac[(n + 2) * (k + 2)] = fpow(fac[(n + 2) * (k + 2)], mod - 2);
	for (int i = (n + 2) * (k + 2); i; --i) ifac[i - 1] = 1LL * ifac[i] * i % mod;
	for (int i = 0; i <= n; ++i)
		for (int j = i; j <= n; ++j)
		{
			
			if (i) f[i][j] = (f[i][j] + f[i - 1][j]) % mod;
			if (j) f[i][j] = (f[i][j] + 1LL * f[i][j - 1] * get((j - 1) * (k - 1) + i, k - 2)) % mod;
			//cerr << "get = " << get(j * (k - 1), k - 2) << endl;
		}
	printf("%d\n", int((1LL * f[n][n] * fac[n]) % mod));
	return 0;
}

Measured memory_bytes: 47488
#include <bits/stdc++.h>
using namespace std;
const int uchiha=1e3+5;
map<int,int> mp;
int main(){
    map<int,int>::iterator it;
int n,w;
cin>>n;
while(n--){
    cin>>w;
    mp[w]++;
}
int c1=0;
for(it=mp.begin();it!=mp.end();it++){
    if(it->second%2==1)
        c1++;
}
cout<<c1;
}

Measured memory_bytes: 4864