akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int sum = accumulate(all(A), 0);
    int cnt = 0;
    rep(i, N) {
        cnt += A[i] >= (sum + 4 * M - 1) / (4 * M);
    }
    write(cnt >= M ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    ll a[3][3] = {};
    bool flag[3][3] = {false};
    ll n;
    rep(i,0,3) rep(j,0,3) cin >> a[i][j];

    cin >> n;
    ll b[n];
    rep(i,0,n){
        cin >> b[i];
        rep(j,0,3) rep(k,0,3) if(a[j][k] == b[i]) flag[j][k] = true;
    }

    rep(i,0,3){
        rep(j,0,3){
            if(!flag[i][j]) break;
            else if(j == 2){
                cout << "Yes" << endl;
                return 0;
            }
        }

        rep(j,0,3){
            if(!flag[j][i]) break;
            else if(j == 2){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    rep(i,0,3){
        if(!flag[i][i]) break;
        else if(i == 2){
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(i,0,3){
        if(!flag[i][2-i]) break;
        else if(i == 2){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

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

int main() {
    int N;
    cin >> N;
  	int Alice = 0;
  	int Bob = 0;
    int a;
    vector<int> Card(N);
    //全てのカードをCardに登録する
  	for(int i = 0; i < N; i++){
        cin >> a;
        Card.at(i) = a;
    }
    //Card配列の中身を小さい順に並び替える
  	sort(Card.begin(), Card.end());
    //Card配列の中身を大きい順に並び替える
  	reverse(Card.begin(), Card.end());
    //Card配列の要素番号が偶数の場合はAliceの得点、奇数の場合はBobの得点とする
  	for(int i = 0; i < N; i++){
       	if(i % 2 == 0){
        	Alice += Card.at(i);
        }else{
        	Bob += Card.at(i);
        }
    }
  	cout << Alice - Bob << endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i=0; i < N; i++){
    cin >> vec.at(i);
  }
  
  int ans=0;
  
  for (int i=0; i < N - 2; i++){
    for (int j=i+1; j < N - 1; j++){
      for (int k=j+1; k < N; k++){
        if (vec.at(i) != vec.at(j) && vec.at(k) != vec.at(j) && vec.at(i) != vec.at(k)){
          if (vec.at(i) < vec.at(j) + vec.at(k) && vec.at(j) < vec.at(i) + vec.at(k) && vec.at(k) < vec.at(j) + vec.at(i)){
           ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
N, Q = map(int, input().split())
Query = [list(map(int, input().split())) for _ in range(Q)]
ans = 0

for T in range(1, 3):
    Depth = [N-2]*N
    left = N
    up = N-2
    for t, x in Query:
        if t == T:  # |
            if left < x:
                ans += Depth[x]
            else:
                for i in range(x, left):
                    Depth[i] = up
                left = x
                ans += up
        else:  # -
            up = min(up, x-2)
        #print(f"ans={ans}, up={up}")
    #print("---")

print((N-2)**2-ans)


Measured memory_bytes: 42156
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    ll ans = 1;
    ll mod = 1000000007;
    map<int,int> res;
    REP(j,1,n+1) {
        int num = j;
        for(ll i = 2; i <= num; ++i) {
            if(num%i) continue;
            while(num%i == 0) {
                num/=i;
                res[i]++;
            }
        }
    }
    for(auto val : res) {
        ans *= (val.second+1);
        ans%=mod;
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll i,j,k,n,m,s,x,y;
    cin>>n>>m>>x>>y;
    double mn=m*n/2.0;
    cout<<mn<<" ";
    if(x*2==n&&y*2==m) cout<<1;
    else cout<<0;

}


Measured memory_bytes: 3748
from enum import Enum
import sys

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

class Point():
    def __init__(self,arg_x,arg_y):
        self.x = arg_x
        self.y = arg_y

def calc_len(a,b):
    from math import sqrt
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))

x1,y1,x2,y2 = map(float,input().split())

p1 = Point(x1,y1)
p2 = Point(x2,y2)

print("%.10f"%calc_len(p1,p2))


Measured memory_bytes: 6356
n = int(input())
A = [int(x) for x in input().split()]

mx = A[0]
humidai = 0
for i in range(1, n):
    if A[i] < mx:
        humidai += mx-A[i]
    elif A[i] > mx:
        mx = A[i]

print(humidai)

Measured memory_bytes: 94072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
	int n;
	cin >> n;
	vector<tuple<string,int,int>> tp(n);
	rep(i,n){
		string a;
		int b;
		cin >> a >> b;
		tp[i] = make_tuple(a,-b,i+1);
	}
	sort(tp.begin(),tp.end());
	rep(i,n){
		cout << get<2>(tp[i]) << endl;
	}
	return 0;
}



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

using ll=long long;
const ll INF=1e10;
int main(){
    int n;
    cin>>n;
    vector<vector<ll>> a(n,vector<ll>(n));
    for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>a[i][j];

    vector<vector<ll>> d(n,vector<ll>(n,INF));
    for(int i=0;i<n;i++) d[i][i]=0;
    using Edge=pair<ll,pair<int,int>>;
    vector<Edge> edges;
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            edges.push_back({a[i][j],{j,i}});
        }
    }
    sort(edges.begin(),edges.end());
    ll res=0;
    for(auto &e:edges){
        ll len=0;        
        int u,v;
        len=e.first;
        u=e.second.first,v=e.second.second;
        if(len<d[u][v]){
            d[u][v]=d[v][u]=len;
            res+=len;
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    d[i][j]=min(d[i][j],d[i][u]+d[u][v]+d[v][j]);
                    d[i][j]=min(d[i][j],d[i][v]+d[v][u]+d[u][j]);
                    d[j][i]=d[i][j];
                }
            }
            
        }
    }
    cout<<(d==a ? res : -1LL)<<endl;
    
    return 0;
}

Measured memory_bytes: 2808
using System;
using System.IO;
using System.Linq;

namespace ABC125D
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Solve();
        }

        void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

            var numMinus = A.Where(value => value < 0).Count();
            var minAbs = A.Select(value => Math.Abs(value)).Min();

            var ans = 0L;

            Console.Error.WriteLine("munMinus : " + numMinus);
            Console.Error.WriteLine("minAbs   : " + minAbs);

            if (numMinus % 2 == 0)
            {
                // 全部プラスにできる
                ans = A.Select(value => Math.Abs(value)).Sum();
            }
            else
            {
                // 一つマイナスが残る
                ans = A.Select(value => Math.Abs(value)).Sum() - 2 * minAbs;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 29532
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    int N;cin>>N;
    string S;cin>>S;
    REP(i,S.size()){
        S[i]=(S[i]-'A'+N)%26+'A';
    }
    cout<<S<<endl;
}

Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        n: usize,
        mut a: [usize;n],
    }

    a.sort();
    println!("{}", a[n-1] - a[0]);

}


Measured memory_bytes: 2172
#include <algorithm>

namespace rika
{
  template <typename T>
  class edge
  {
  public:
    int to;
    T cost;
    
    edge() = default;
    edge(const edge<T>&) = default;
    edge(edge<T>&&) = default;
    edge& operator =(const edge<T>&) = default;
    edge& operator =(edge<T>&&) = default;

    ~edge() = default;

    edge(int _to, T _cost) : to(_to), cost(_cost) {}
  };
}

#include<bits/stdc++.h>
using namespace std;
using namespace rika;
namespace rika
{
  namespace internal
  {
    template <typename TValue, typename TGraph>
    std::pair<TValue, int> visit(int from, int v, const TGraph &g)
    {
      if(v < 0)
        throw "test";
      auto r = std::make_pair(TValue(), v);
      try{
      for(auto it = g[v].begin(); it != g[v].end(); ++it)
      {
        if(it->to == from)
          continue;
        auto r2 = visit<TValue>(v, it->to, g);
        if(r2.first + it->cost >= r.first)
          r = std::make_pair(r2.first + it->cost, r2.second);
      }
      }catch(const std::out_of_range &e){}
      return r;
    }
  }

  template <typename TValue, typename TGraph>
  TValue tree_diameter(const TGraph &g)
  {
    using namespace internal;
    auto r1 = visit<TValue>(-1, 0, g);
    auto r2 = visit<TValue>(-1, r1.second, g);
    return r2.first;
  }
}

#include<bits/stdc++.h>
using namespace std;
using namespace rika;
int main()
{
  int N;
  cin >> N;
  vector<vector<edge<int>>> g(N * 10);
  for(int i = 0; i < N - 1; i++)
  {
    int s, t, w;
    cin >> s >> t >> w;
    g[s].push_back(edge<int>(t, w));
    g[t].push_back(edge<int>(s, w));
  }
  cout << tree_diameter<int>(g) << endl;
}

Measured memory_bytes: 35428
#include <bits/stdc++.h>
#define pb push_back
#define INF 1LL<<50
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
int n;
vl a;
vvl al,dpa,dpb;
vl up(vl v, vl u1, vl u2, bool ml) {
	vl ret(v.size()+u1.size()+1,INF);
	for(int i=0;i<v.size();i++) {
		if(v[i] == INF) {continue;}
		for(int j=0;j<u1.size();j++) {
			if(i+j-1 >= 0) {
				if(u1[j] != INF) {ret[i+j-1] = min(ret[i+j-1],v[i]+u1[j]);}
				if(!ml && u2[j] != INF) {ret[i+j-1] = min(ret[i+j-1],v[i]+u2[j]);}
			}
			if(u1[j] != INF) {ret[i+j] = min(ret[i+j],v[i]);}

			if(u2[j] < 0) {ret[i+j] = min(ret[i+j],v[i]);}
		}
	}
	return ret;
}
void dfs(int v, int p) {
	dpa[v].pb(INF);
	dpb[v].pb(INF);
	dpa[v].pb(a[v] > 0?a[v]:INF);
	dpb[v].pb(a[v]);
	for(int i=0;i<al[v].size();i++) {
		int u = al[v][i];
		if(al[v][i] == p) {continue;}
		dfs(al[v][i],v);
		dpa[v] = up(dpa[v],dpa[u],dpb[u],true);
		dpb[v] = up(dpb[v],dpa[u],dpb[u],false);
	}
}
int main() {
	scanf("%d ",&n);
	al.assign(n,vl());
	dpa.assign(n,vl());
	dpb.assign(n,vl());
	for(int i=0;i<n;i++) {
		int t;
		scanf("%d ",&t);
		a.pb(t);
	}
	for(int i=0;i<n-1;i++) {
		int t,u;
		scanf("%d %d ",&t,&u);
		t--;u--;
		al[t].pb(u);
		al[u].pb(t);
	}
	dfs(0,-1);
	for(int i=0;i<dpa[0].size();i++) {
		//printf("%lld %lld\n",dpa[0][i],dpb[0][i]);
		if(dpa[0][i] != INF || dpb[0][i] < 0) {printf("%d\n",i-1);
			return 0;
		}
	}
}

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

using namespace std;

int main(){
    string S(10, '\0');
    cin >> S;
    if(S.at(0) != 'A'){
        cout << "WA\n";
        return 0;
    } else{
        S.at(0) = 'a';
    }
    int cnt = 0;
    bool flag = false;
    for(const auto &itr : S){
        if(!islower(itr)){
            if(itr != 'C' || flag){
                cout << "WA\n";
                return 0;
            }
            flag = true;
            if(cnt < 2 || S.size() - 2 < cnt){
                cout << "WA\n";
                return 0;
            }
        }
        cnt++;
    }
    if(flag) {
        cout << "AC\n";
    } else{
        cout << "WA\n";
    }
    return 0;
}


Measured memory_bytes: 256
#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 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 = 1e3 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = {1171, 3307}, Mod = {1e9 + 7, 1e9 + 9};
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, m, v, u, timer, V, U, p[N][N], d[N][N];
queue < int > q;
vi g[N];


main () {
	cin >> n >> m;
	while (m--) {
		cin >> v >> u;
		g[v].pb(u);
	}
	
	forn (i, 1, n) {
		memset(p[i], -1, sizeof(p[i]));
		p[i][i] = 0;
		q.push(i);

		while (sz(q)) {
			v = q.front();
			q.pop();

			for (auto to : g[v]) 
				if (p[i][to] == -1) {
					p[i][to] = v;				
					d[i][to] = d[i][v] + 1;
					q.push(to);
				}
		}
	}

	int ii = 0, jj = 0;
	forn (i, 1, n)
		forn (j, i + 1, n)
			if (p[i][j] > -1 && p[j][i] > -1 && (!ii || d[i][j] + d[j][i] < d[ii][jj] + d[jj][ii]))  {
				ii = i;
				jj = j;				
			}

	if (!ii) {
		cout << -1;
		return 0;
	}
		

	int i = ii, j = jj;
	set < int > ans;

	ii = i, jj = j;
	while (jj != ii) {
		ans.insert(jj);
		jj = p[ii][jj];
	}
	ii = i, jj = j;
	while (ii != jj) {
		ans.insert(ii);
		ii = p[jj][ii];
	}

	cout << sz(ans) << endl;
	for (auto x : ans)
		cout << x << endl;
}

    


Measured memory_bytes: 16256
N=int(input())
A=list(map(int,input().split()))
A.sort()

B=[]
for i in range(1,N-1):
    if A[i]>=0:
        B.append([A[0],A[i]])
        A[0]-=A[i]
    else:
        B.append([A[-1],A[i]])
        A[-1]-=A[i]
print(A[-1]-A[0])
for b in B:
    print(b[0],b[1])
print(A[-1],A[0])


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

int64_t jou(int tei, int sisu){
  int64_t res = 1;
  for(;sisu>0;sisu--){
    res *= tei;
  }
  return res;
}

int64_t solve(int64_t S, int digit, int i){
  if(i == 1) return S%10;
  
  int64_t res;
  int64_t sumi = 0;
  for(int j=0; j<=i-2; j++){
    sumi += jou(10, j)*jou(2,i-2-j);
  }
  sumi += jou(10, i-1);
  
  res = sumi*( (S/jou(10,i-1)) %10) + solve(S, digit, i-1) *2;
  
  return res;
}


int main() {
  int64_t S;
  cin >> S;
  
  int digit=0;
  for(int64_t iS=S; iS>0; digit++){
    iS /= 10;
  }
  
  cout << solve(S, digit, digit) << endl;
}

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

using namespace std;
typedef long long ll;
const long double pi=3.14159265358979323846;
#define x  first
#define y  second
#define deb(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
ll isPar(string s)
{
    ll n=s.size();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            return 0;
        }
    }
    return 1;
}

ll isP(ll x)
{
    for(int i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)return 0;
    }
    return 1;
}

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    //freopen("op.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        string s,t;
        cin>>s>>t;
        ll d=0;
        for(int i=0;i<s.size();i++)d+=s[i]!=t[i];
        cout<<d;
    }
    return 0;
}


Measured memory_bytes: 3864
#include<stdio.h>
int main() {
    int n,g,i,j,t,k,res,ans=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++) {
        scanf("%d",&res);
        if(i%2==1 && res%2==1) ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1724
import java.util.*; 
 
class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
       int n = Integer.parseInt(sc.next());
       
  		int[] a=new int[n];
		for(int c=0;c<n;c++){
    		a[c]=Integer.parseInt(sc.next());
    	}
  Map<Integer, Long> map1 = new HashMap<Integer, Long>();
  		int[] b=a.clone(); 
  		Arrays.sort(b);
  		long f=0;
  		long[] ans=new long[n];
  		long count=0;
  		
  		for(int c=1;c<b.length;c++){
        	if(b[c-1]==b[c]){
            	count++;
            }else{
              count++;
              map1.put(b[c-1],count);
              f+=count*(count-1)/2;
              count=0;
              }
        
        }
          count++;
         map1.put(b[b.length-1],count);
  		f+=count*(count-1)/2;
  
  		for(int d=0;d<b.length;d++){
          long s=map1.get(a[d]);
          ans[d]=f-s*(s-1)/2;
          ans[d]+=(s-1)*(s-2)/2;
        }
  
  	for(long e:ans){
    	System.out.println(e);
    }      
  		
   
    
}
}


Measured memory_bytes: 70748
package main

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

var rdr = bufio.NewScanner(os.Stdin)

func main() {
	rdr.Scan()
	str := strings.Fields(rdr.Text())
	a, _ := strconv.Atoi(str[0])
	b, _ := strconv.Atoi(str[1])
	k, _ := strconv.Atoi(str[2])
	var last int

	for i := a; i < a+k; i++ {
		if i <= b {
			fmt.Println(i)
			last = i
		} else {
			break
		}
	}

	for i := b-k+1; i <= b; i++ {
		if i > last {
			fmt.Println(i)
		}
	}
}

Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  ll c;
  cin >> n >> c;
  VL x(n), v(n);
  REP(i, 0, n) cin >> x[i] >> v[i];
  VL lef(n + 1), rig(n + 1);
  REP(i, 0, n) lef[i + 1] = lef[i] + v[i];
  for (int i = n - 1; i >= 0; --i) rig[i] = rig[i + 1] + v[i];
  ll ma = 0;
  VL lef_ma(n + 1), rig_ma(n + 1);
  REP(i, 0, n) lef_ma[i + 1] = max(lef_ma[i], lef[i + 1] - x[i]);
  for (int i = n - 1; i >= 0; --i)
    rig_ma[i] = max(rig_ma[i + 1], rig[i] - c + x[i]);
  ma = max(ma, max(rig_ma[0], lef_ma[n]));
  if (0) {
    REP(i, 0, n + 1) DEBUGP(lef[i]);
    REP(i, 0, n + 1) DEBUGP(rig[i]);
    REP(i, 0, n + 1) DEBUGP(lef_ma[i]);
    REP(i, 0, n + 1) DEBUGP(rig_ma[i]);
  }
  REP(i, 0, n) {
    ma = max(ma, lef[i + 1] - 2 * x[i] + rig_ma[i + 1]);
    ma = max(ma, rig[i] - 2 * (c - x[i]) + lef_ma[i]);
  }
  cout << ma << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
ll MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}
ll modpow(ll x, ll y, ll m) {
    if (y == 0) return 1;
    ll res = modpow(x, y / 2, m);
    return res * res % m * (y & 1 ? x : 1) % m;
}
ll modinv(ll x) { return modpow(x, MOD - 2, MOD); }
 
int main(){
    ll A,B,C; cin >> A >> B >> C;
    if((A == B && B == C) || (A != B && B != C && C != A)) print("No");
    else print("Yes");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    int N,W,v,w,ans=0;
    scanf("%d %d",&N,&W);
    vector<int> dp(W+1);
    fill(dp.begin(), dp.end(), 0);
    for(int i=0;i<N;i++){
        scanf("%d %d",&v,&w);
        dp[w]=max(dp[w],v);
        for(int j=0;j<W-w+1;j++){
            if(dp[j]!=0){
                dp[j+w]=max(dp[j+w],dp[j]+v);
            }
        }
    }
    printf("%d\n",*max_element(dp.begin(),dp.end()));
    return 0;
}

Measured memory_bytes: 1208
#include<iostream>
using namespace std;
int main(){
	int n,x;
	int a=0;

	while(1){
		cin>>n>>x;
		if(n==0 && x==0)
			break;

		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				for(int k=j+1;k<=n;k++){
					if(i+j+k==x)
						a++;
				}
			}
		}
		cout<<a<<endl;
		a=0;
	}
}
					

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

int main() {
    int n;
    cin >> n;
    vector<double> x(n);
    vector<double> y(n);
    for (int i=0;i<n;i++){
        cin >>x.at(i) >> y.at(i);
    }
    vector<int> a(n);
    int way=1;
    for (int i=0;i<n;i++){
        a.at(i) = i;
        way *= (i+1);
    }
    double sum=0;
    do{
        for (int i=1;i<n;i++){
            double nw = a.at(i);
            double bf = a.at(i-1);
            sum+=sqrt(pow(x.at(nw)-x.at(bf),2)+pow(y.at(nw)-y.at(bf),2));
        }
    }while(next_permutation(a.begin(),a.end()));
    printf("%lf",sum/way);
    return 0;
}



Measured memory_bytes: 256
// 解き直し.
// https://img.atcoder.jp/nikkei2019-qual/editorial.pdf
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
const int MAX = 101010;
int iDegree[MAX]; // 各頂点における入次数.
int ans[MAX];     // 各頂点における親頂点.

// グラフをトポロジカルソートする.
// https://ja.wikipedia.org/wiki/トポロジカルソート
// ※トポロジカルソートの動作確認用.
// @param G: グラフ.
// @param N: 頂点数.
// @param s: グラフの探索開始頂点(※入力辺を持たない頂点(根)).
// @return: 特に無し.
void tSort(vvi &G, int N, int s){
    // 1. 変数準備.
    vi L;         // トポロジカルソートした結果を蓄積する空リスト.
    queue<int> q; // 入力辺を持たないすべての頂点の集合(空のキュー).
    
    // 2. 探索開始頂点 s をキュー q に追加.
    q.push(s);
    while(!q.empty()){
        // 3. キューから取り出す.
        int n = q.front();
        q.pop();
        
        // 4. L に n を 追加.
        L.pb(n);
        
        // 5. 取り出した要素を処理.
        for(auto &m : G[n]){
            // 6. n の 出力辺 e を グラフから削除.
            iDegree[m]--;
            
            // 7. m がその他の入力辺を持っていなければ, q に 追加.
            if(!iDegree[m]) q.push(m), ans[m] = n + 1;
        }
    }
    
    // 8. グラフに辺が残っている場合は, 閉路があり, 
    // DAG(Directed Acyclic Graph)でないので中断.
    bool isDAG = true;
    rep(i, N){
        if(iDegree[i]){
            isDAG = false;
            break;
        }
    }
    assert(isDAG != false); // DAGでない場合.
    return;
}

int main(){
    
    // 1. 入力情報.
    int N, M, a, b;
    scanf("%d %d", &N, &M);
    vvi G(N);
    rep(i, N + M - 1){
        scanf("%d %d", &a, &b);
        a--, b--;
        G[a].pb(b);
        iDegree[b]++;
    }
    
    // 2. 入次数ゼロの頂点(根)は？
    int root = -1;
    rep(i, N){
        if(!iDegree[i]){
            root = i;
            break;
        }
    }
    assert(root != -1); // 根が見つからなかった場合.
    
    // 3. Topological Sort.
    tSort(G, N, root);
    
    // 4. 出力.
    rep(i, N) printf("%d\n", ans[i]);
    return 0;
    
}

Measured memory_bytes: 10116
#include<bits/stdc++.h>
    #include<chrono>
     
    using namespace std;
    using namespace std::chrono;
    typedef long long ll;
    typedef vector<int> vi;
    typedef pair<int,int> pi;
    #define F first
    #define S second
    #define PB push_back
    #define EB emplace_back
    #define MP make_pair
    #define REP(i,a,b) for(i=a;i<=b;i++)
    #define RAP(i,a,b) for(i=a;i>=b;i--)

    int main(){
    	ios::sync_with_stdio(0);
    	cin.tie(0);
    	int n;
        string s;
        cin>>n;
        cin>>s;
        if(n&1){
            cout<<"No"<<"\n";
        }
        else{
            int i,j;
            i=0;
            j=n/2;
            while(j<=n-1&&s[i]==s[j]){
                i++;
                j++;
            }
            if(j==n){
                cout<<"Yes"<<"\n";
            } 
            else{
                cout<<"No"<<"\n";
            }
        }
        return 0;	
    }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
#define COUT(x) cout<<(x)<<endl
#define M map<int,int>
#define S set<int>
#define PQ priority_queue


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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	int ans = 0;
	for (int b = 1; b <= n; b++) {
		int p = n / b; int r = n % b;
		ans += p * max((int)0, b - k) + max((int)0, r - k + 1);
	}
	if(k!=0)cout << ans << endl;
	else cout << ans - n << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007

using namespace std;

int main(void) {
	int n;
	char s[50][50];
	int count[50][26] = {};
	int point[26] = {};
	char moji;

	cin >> n;

	FOR(i, 0, n - 1) {
		cin >> s[i];
		FOR(t, 0, 49) {
			if (s[i][t] == '\0') {
				break;
			}
			FOR(u, 0, 25) {
				if (s[i][t] == 'a' + u) {
					count[i][u]++;
					break;
				}
			}
		}
	}
	FOR(i, 0, 25) {
		point[i] = count[0][i];
		FOR(t, 1, n - 1) {
			if (count[t][i] < point[i]) {
				point[i] = count[t][i];
			}
		}
	}
	FOR(i, 0, 25) {
		moji = 'a' + i;
		FOR(t, 1, point[i]) {
			cout << moji;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

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

  vector<vector<ll>> dp(N + 1, vector<ll>(N + 1));
  for (int i = 0; i <= N; i++) {
    dp[i][i] = 0;
  }

  for (int len = 1; len <= N; len++) {
    for (int i = 0; i + len <= N; i++) {
      int j = i + len;

      if ((N - len) % 2 == 0) {
        dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1]);
      } else {
        dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1]);
      }
    }
  }

  cout << dp[0][N] << endl;
}

Measured memory_bytes: 70784
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
const int INF=1e9+7;

struct st{int p,b,c;};

bool operator < (const st &a,const st &b){return a.c>b.c;}

int n,m;
vector<int> g[100005];
map<int,int> d[100005];
map<int,vector<int> > ve[100005];
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		u--;v--;
		ve[u][w].push_back(v);
		ve[v][w].push_back(u);
		g[u].push_back(w);
		g[v].push_back(w);
	}
	priority_queue<st> pq;
	pq.push((st){0,0,0});
	d[0][0]=0;
	while(!pq.empty()){
		st p=pq.top();
		pq.pop();
		if(d[p.p][p.b]!=p.c) continue;
		if(d[p.p].find(0)==d[p.p].end()||d[p.p][0]>p.c){
			d[p.p][0]=p.c;
			pq.push((st){p.p,0,p.c});
		}
		if(p.b==0){
			for(int i=0;i<g[p.p].size();i++){
				int v=g[p.p][i];
				if(d[p.p].find(v)==d[p.p].end()||d[p.p][v]>p.c+1){
					d[p.p][v]=p.c+1;
					pq.push((st){p.p,v,p.c+1});
				}
			}
			continue;
		}
		for(int i=0;i<ve[p.p][p.b].size();i++){
			int v=ve[p.p][p.b][i];
			if(d[v].find(p.b)==d[v].end() || d[v][p.b]>p.c){
				d[v][p.b]=p.c;
				pq.push((st){v,p.b,p.c});
			}
		}
	}
	int ans=INF;
	for(map<int,int>::iterator it=d[n-1].begin();it!=d[n-1].end();it++) ans=min(ans,(it->second));
	if(ans==INF)
	puts("-1");
	else printf("%d\n",ans);
	//system("pause");
	return 0;
}

Measured memory_bytes: 84276
#include <bits/stdc++.h>
#include <atcoder/all>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;
using namespace atcoder;

using ll = long long;
using P = pair<int,int>;

constexpr int INF = 1001001001;

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

int main() {
    int n;
    cin >> n;
    vector<P> p(n);
    map<P, int> id;
    vector<int> y2x(n);
    rep (i, n) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        p[i] = make_pair(x, y);
        id[p[i]] = i;
        y2x[y] = x;
    }
    
    sort(p.begin(), p.end());
    dsu d(n);
    priority_queue<int, vector<int>, greater<int>> pq;
    pq.push(p[0].second);
    rep (i, 1, n) {
        int mi = pq.top();
        while (!pq.empty() && pq.top() < p[i].second) {
            int k = pq.top();
            d.merge(id[p[i]], id[make_pair(y2x[k], k)]);
            pq.pop();
        }
        chmin(mi, p[i].second);
        pq.push(mi) ;
    }
    
    rep (i, n) cout << d.size(i) << endl;
    
    return 0;
}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

int a[100];
int cells[100][100]; // r * c

int main() {
  double N;
  cin >> N;

  double ans;
  ans = floor(N / 2) / N;
  fcout << (1 - ans) << BR;
  return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

struct UnionFind{
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return 0;
        if(data[y]<data[x])swap(x,y);
        data[x]+=data[y],data[y]=x;
        return 1;
    }
    bool findSet(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
  	int n,a,b;
  	cin>>n>>a>>b;
  	cout<<n/(a+b)*a+min(n%(a+b),a)<<endl;
  	
}







Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define N 100001

//function Partition
int Partition(int a[],int p,int r){
  int x,i,j,st;

  x=a[r];
  i=p-1;

  for(j=p;j<=r-1;j++){
    if(a[j]<=x){
      i++;

      //exchange a[i] and a[j]
      st=a[i];
      a[i]=a[j];
      a[j]=st;
    }
  }

  //exchange a[i] and a[j]
    st=a[i+1];
    a[i+1]=a[r];
    a[r]=st;
    return i+1;

}

int main(){

  int a[N],n,i;
  int f;
  //load number
  cin >>n;
  //load data
  for(i=0;i<n;i++){
    cin >>a[i];
  }

  //execute Partition
  f=Partition(a,0,n-1);


  //print
  for(i=0;i<n;i++){
    if(i!=f)cout <<a[i];
    if(i==f)cout <<"["<<a[i]<<"]";
    if(i!=n-1)cout <<" ";
  }
  cout <<endl;

  return 0;
}

Measured memory_bytes: 1252
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int A = sc.nextInt();
		if (H % A == 0) {
			System.out.print(H / A);
		} else {
			System.out.print(H / A + 1);
		}
	}
}

Measured memory_bytes: 21460
s=list(input())
flag=1
if s[0]!='A':
    flag=0
if 'C' not in s[2:-1]:
    flag=0
if s.count('C')!=1:
    flag=0
if 'A' in s:
    s.remove('A')
if 'C' in s:
    s.remove('C')
s=''.join(s)
if s.islower():
    pass
else:
    flag=0
if flag==1:
    print('AC')
else:
    print('WA')

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

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


Measured memory_bytes: 256
object Main{
  def check(a:Int, b:Int, c:Int) = {
    var d:Int = 0
    for(i <- a to b){
      if(c % i == 0)
        d += 1
    }
    println(d)
  }
  def main(args:Array[String]) = {
    val scanner = new java.util.Scanner(System.in)
    val a = scanner.nextInt
    val b = scanner.nextInt
    val c = scanner.nextInt
    check(a, b, c)
  }
}

Measured memory_bytes: 45140
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>

using namespace std;
int h, w, ans[300][300], cnt = 0, p = 0, k, sum[100001];
char s[300][310];
int main() {
  scanf("%d%d%d", &h, &w, &k);
  for (int i = 0; i < h; i++) {
    scanf("%s", s[i]);
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        cnt++;
        ans[i][j] = cnt;
        for (int k = j - 1; k >= 0; k--) {
          if (ans[i][k] == 0) {
            ans[i][k] = cnt;
          } else {
            break;
          }
        }
        for (int k = j + 1; k < w; k++) {
          if (s[i][k] == '.') {
            ans[i][k] = cnt;
          } else {
            break;
          }
        }
      }
    }
  }
  for (int i = 0; i < h; i++) {
    if (ans[i][0] == 0) {
      for (int j = i + 1; j < h; j++) {
        if (ans[j][0]) {
          p = j;
          break;
        }
      }
      for (int j = i; j < p; j++) {
        for (int k = 0; k < w; k++) {
          ans[j][k] = ans[p][k];
        }
      }
    }
  }
  p = h;
  for (int i = h - 1; i >= 0; i--) {
    if (ans[i][0] == 0) {
      for (int j = i - 1; j >= 0; j--) {
        if (ans[j][0]) {
          p = j;
          break;
        }
      }
      for (int j = i; j > p; j--) {
        for (int k = 0; k < w; k++) {
          ans[j][k] = ans[p][k];
        }
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      printf("%d ", ans[i][j]);
    }
    printf("\n");
  }
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  string s;
  cin>>s;
  bool ans = true;
  for(int i=1;i<=s.length();i++){
    if(i%2==0&&s[i-1]!='L'&&s[i-1]!='D'&&s[i-1]!='U'){
      ans=false;
    }else if(i%2!=0&&s[i-1]!='R'&&s[i-1]!='U'&&s[i-1]!='D'){
      ans=false;
    }
  }
  if(ans){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
import itertools

n, m, q = list(map(int, input().split()))
a, b, c, d = [0] * q, [0] * q, [0] * q, [0] * q

for i in range(q):
    a[i], b[i], c[i], d[i] = list(map(int, input().split()))
    a[i] -= 1
    b[i] -= 1
# Aは単調増加数列でNこの要素を持って最大でもMまで
ans = 0
for seq in itertools.combinations_with_replacement(range(m), n):
    tmp = 0
    for i in range(q):
        if seq[b[i]]-seq[a[i]] == c[i]:
            tmp += d[i]
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 27136
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a,b,c;
  cin>>a>>b>>c;
  cout<<a[0];
  cout<<b[0];
  cout<<c[0];

  return 0;

}


Measured memory_bytes: 256
A, B, C, X, Y = [int(ax) for ax in input().split()]

mn_ABC = min(A+B, C*2)
mn_xy = min(X, Y)
money_1 = mn_ABC * mn_xy

money_2 = 0
if X > Y:
  mn_AC = min(A, C*2)
  money_2 = mn_AC * (X-Y)
elif X < Y:
  mn_BC = min(B, C*2)
  money_2 = mn_BC * (Y-X)

ans = money_1 + money_2
print(ans)

Measured memory_bytes: 3064
import bisect
n, q = map(int, input().split())
STX = []
for i in range(n):
    s, t, x = map(int, input().split())
    STX.append((s, t, x))
STX.sort(key=lambda _: _[2])
S, T, X = [], [], []
for stx in STX:
    s, t, x = stx
    S.append(s)
    T.append(t)
    X.append(x)
D = [int(input()) for j in range(q)]
A = [-1 for j in range(q)]
B = [-1 for j in range(q)]
for i in range(n):
    l = bisect.bisect_left(D, S[i]-X[i])
    r = bisect.bisect_left(D, T[i]-X[i])
    while l < r:
        if B[l] == -1:
            A[l] = X[i]
            B[l] = r
            l += 1
        else:
            l = B[l]
print(*A, sep='\n')


Measured memory_bytes: 62816
#include <stdio.h>

int main(void) {
    int i,j,k,n,l,ans=0;
    scanf("%d %d", &i,&j);
    int f1[1000][1000]={};
    for(k=0;k<i+1;k++){
        for(l=0;l<j;l++){
            scanf("%d",&n);
            f1[k][l]=n;
        }
    }
    for(k=0;k<i;k++){
            ans = 0;
        for(l=0;l<j;l++){
            ans+=f1[k][l]*f1[i][l];
        }
        printf("%d\n",ans);
    }
    
    return 0;
}

Measured memory_bytes: 4516
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> pairs(N);
	for (int i = 0; i < N; ++i) {
		int tmp, tmp2;
		cin >> tmp >> tmp2;
		pairs[i] = make_pair(tmp2, tmp);
	}

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

	int time_his = 0;
	bool ok_flag = true;
	for (int i = 0; i < N; ++i) {
		if (pairs[i].first - time_his >= pairs[i].second) {
			time_his += pairs[i].second;
		} else {
			ok_flag = false;
			break;
		}
	}
	if (ok_flag) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;


public class Program
{
    int N;
    long[] X;
    long[] L;

    public void Input()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        X = new long[N];
        L = new long[N];

        for (int i = 0; i < N; i++)
        {
            X[i] = sc.NextLong();
            L[i] = sc.NextLong();
        }
    }


    public void Solve()
    {
        Input();
        var robots = new List<Robot>();
        var robots_arr = new Robot[N]; 

        for (int i = 0; i < N; i++)
        {
            var robot = new Robot(X[i] - L[i], X[i] + L[i]);
            robots.Add(robot);
            robots_arr[i] = robot;
        }

        robots.Sort((a, b) => (int)a.r - (int)b.r);
        robots_arr = robots_arr.OrderBy(a => a.r).ToArray();

        int ans = 0;
        long cur = -1001000100;
        for (int i = 0; i < N; i++)
        {
            if (cur <= robots_arr[i].l)
            {
                ans++;
                cur = robots_arr[i].r;
            }
        }
        Console.WriteLine(ans);

    }

    public static void Main(string[] args) => new Program().Solve();
}

public class Robot
{
    public long l { get; set; }
    public long r { get; set; }


    public Robot(long _l, long _r)
    {
        l = _l;
        r = _r;
    }

}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 53792
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
A = list(map(int, input().split()))

cnt = [0] * (N + 1)
for a in A:
    cnt[a] += 1

for i in range(1, N + 1):
    print(cnt[i])

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

int main(){
    int N;
    cin >> N;
    int X = 0;
    double cnt = 0;
    while(X < N) {
        double A;
        cin >> A;
        cnt+=1.0/A;
        X++;
    }
    cout << fixed << setprecision(10) << 1.0/cnt << endl;
}


Measured memory_bytes: 256
file = $stdin
files = file.readlines
file.close
weights = [1,2,4,8,16,32,64,128,256,512]

files.each do | w |
	flug = nil
	(1..10).each do |i|
		weights.combination(i).each do |c|
			if c.reduce{|sum, n| sum + n} == w.to_i then
				puts c.join(" ")
				flug = true
				break
			end
			break if flug == true
		end
	end
end

Measured memory_bytes: 6088
#include <stdio.h>
#include<cmath>
#include<iostream>
using namespace std;
int main()
{
    int A,B;
    cin>>A>>B;

    if(A==B){
        cout<<"Draw \n";
    }
     else if((B==1 || B>A) &&B<=13 &&A!=1){
        cout<<"Bob \n";
    }

    else if ((A==1 || A>B) &&A<=13 &&B!=1){
        cout<<"Alice \n";
    }
else
    cout<<"enter number less than 14\n";

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
int main()
{
	int n; cin >> n;
	for (int i = 1; i <= 9; i++) {
		for (int g = 1; g <= 9; g++) {
			if (i * g == n) {
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
}



Measured memory_bytes: 256