akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int mx = max({a, b, c});
  if (mx % 2 != (a + b + c) % 2) ++mx;
  cout << (3 * mx - a - b - c) / 2 << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF pow(10, 9) + 7
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int ll;
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;
#define chmax(x, y) x = max(x, y)

ll a[3005][3005];
ll dp[3005][3005][4];

int main(){
    
    fastio;
    
	ll R, C, n;
	cin >> R >> C >> n;
	rep(i, n){
		ll in1, in2, in3;
		cin >> in1 >> in2 >> in3;
		a[in1 - 1][in2 - 1] = in3;
	}
		
	rep(i, R){
		rep(j, C){
			dp[i + 1][j + 1][0] = max(dp[i][j + 1][3], dp[i + 1][j][0]);
			for(int k = 2; k >= 0; k--){
				chmax(dp[i][j][k + 1], dp[i][j][k] + a[i][j]);
			}
			rep(k, 4){
				chmax(dp[i + 1][j][0], dp[i][j][k]);
				chmax(dp[i][j + 1][k], dp[i][j][k]);
			}
		}
	}
				
	ll ans = 0;
	rep(k, 4) chmax(ans, dp[R - 1][C - 1][k]);
	cout << ans << endl;   
    
	return 0;
	
}

Measured memory_bytes: 355792
#include<stdio.h>

int main(void){
    int a,b,c,i,count = 0;
    scanf("%d %d %d",&a,&b,&c);

    for(i = a;i <= b;i++)
        if(c % i == 0)
            count++;
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

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

    for (int i = 0; i < M; ++i){
        cin >> A.at(i);
    }

    int sum = accumulate(A.begin(), A.end(), 0);

    int ans = max(-1, N - sum);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int N;
  cin >> N;
  int H[N];
  for (int i=0; i<N; i++) cin >> H[i];
  
  int maxh = H[0];
  int count = 0;
  for (int i=0; i<N; i++) {
    if (maxh <= H[i]) {
      count++;
      maxh = max(maxh,H[i]);
    }
  }
  cout << count << endl;
}

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

int main(){
    int H,W;
    cin >> H >> W;
    char S[60][60];
    int i,j,k,l;
    for(i=1; i<=H; i++){
        for(j=1; j<=W; j++){
            cin >> S[i][j];
        }
    }
    int count;

    for(i=1; i<=H; i++){
        for(j=1; j<=W; j++){
            if(S[i][j]=='.'){
                count=0;
                for(k=0; k<3; k++){
                    for(l=0; l<3; l++){
                        if(S[i-1+k][j-1+l]=='#') count++;
                    }
                }
                cout << count;
            }
            else cout << S[i][j];
        }
        cout << endl;
    }
        
        return 0;
}

Measured memory_bytes: 3604
N = int(input())
numbers = list(map(int, input().split()))

numbers_abs = [abs(n) for n in numbers]
sum_abs = sum(numbers_abs)
min_abs = min(numbers_abs)

count_negative = sum([1 for n in numbers if n < 0])

answer = sum_abs
if (count_negative % 2 == 1):
  answer = sum_abs - 2 * min_abs

print(answer)


Measured memory_bytes: 14412
fun main(args: Array<String>) {
    val s = readLine()!!
    var (x, y) = readLine()!!.split(" ").map { it.toInt() }
    val t = s.split("T").map { it.length }
    val xs = t.filterIndexed { id, v -> id % 2 == 0 }
    val ys = t.filterIndexed { id, v -> id % 2 != 0 }
    var xSet = setOf(xs[0])
    var ySet = setOf(0)
    for ((i, d) in xs.withIndex()) {
        if (i==0) continue
        xSet = xSet.toList().map{listOf(it-d, it+d)}.flatten().toSet()
    }
    for ((i, d) in ys.withIndex()) {
        ySet = ySet.toList().map{listOf(it-d, it+d)}.flatten().toSet()
    }
    println(if (x in xSet && y in ySet) "Yes" else "No")
}


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

int main(void){
  char s[3];
  int i, c=0;
  scanf("%s",s);
  for(i=0;i<3;i++) if(s[i]=='1') c++;
  printf("%d\n",c);
  return 0;
}


Measured memory_bytes: 128
A,B=map(int,input().split())
i=0
while i<1001:
    X=int(i*0.08)
    Y=int(i*0.10)
    if A==X and B==Y:
        break
    i=i+1
if i==1001:
    i=-1
    print(i)
else:
    print(i)


Measured memory_bytes: 2940
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		if (x < a) {
			System.out.println("0");
		} else {
			System.out.println("10");		
		}
		return;
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int H,W;
    cin >> H >> W;
    vector<string> S(H);
    rep(i,H)cin >> S[i];
    vector<vector<int>> dp(H,vector<int>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int c = 0;
            if(S[i][j]=='#'){
                c=1;
            }
            if(i==0){
                if(j==0){
                    dp[0][0]=c;
                }else{
                    if(S[0][j-1]=='#'){
                        c=0;
                    }
                    dp[0][j]=dp[0][j-1]+c;
                }
            }else{
                if(j==0){
                    if(S[i-1][0]=='#'){
                        c=0;
                    }
                    dp[i][0]=dp[i-1][0]+c;
                }else{
                    int c1,c2;
                    if(S[i][j-1]=='#'){
                        c1=0;
                    }else{
                        c1=1;
                    }
                    if(S[i-1][j]=='#'){
                        c2=0;
                    }else{
                        c2=1;
                    }
                    if(c==0){
                        dp[i][j]=min(dp[i][j-1],dp[i-1][j]);
                    }else{
                        dp[i][j]=min(dp[i][j-1]+c1,dp[i-1][j]+c2);
                    }
                }
            }
        }
    }
    cout << dp[H-1][W-1] << endl;
    return 0;
}

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

namespace ABC163
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }

        public static void a()
        {
            double r = double.Parse(Console.ReadLine());
            double ans = r * 2 * Math.PI;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 18648
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vvc g(n,vc(n)) ;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin >> g.at(i).at(j) ;
	ll ans = 0 ;
	auto check = [&](){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(g.at(i).at(j)!=g.at(j).at(i)){
					return 0LL ;
				}
			}
		}
		return n ;
	} ;
	auto move = [&](){
		vc sub(n) ;
		for(int i=0;i<n;i++) sub.at(i) = g.at(i).at(0) ;
		for(int i=0;i<n;i++) for(int j=0;j<n-1;j++) g.at(i).at(j) = g.at(i).at(j+1) ;
		for(int i=0;i<n;i++) g.at(i).at(n-1) = sub.at(i) ;
	} ;
	for(int i=0;i<n;i++){
		ans += check() ;
		move() ;
	}
	cout << ans << endl ;
}


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

typedef long long ll;
const ll MOD=1e9+7;

ll add(ll x, ll y) {return (x+y)%MOD;}
ll mlt(ll x, ll y){return (x*y)%MOD;}

bool prohibited(int a, int b, int c, int d){
  if(      b==1&&c==2&&d==3) return true;
  if(a==1      &&c==2&&d==3) return true;
  if(a==1&&b==2      &&d==3) return true;
  if(      b==2&&c==1&&d==3) return true;
  if(      b==1&&c==3&&d==2) return true;
  return false;
}

int main(){
  int N;cin>>N;
  ll dp[N+10][4*4*4*4][2];
  memset(dp, 0, sizeof(dp));

  dp[0][0][0]=1;

  for (int i=1;i<=N;++i){
    for (int a=0;a<4;++a){
      for (int b=0;b<4;++b){
        for (int c=0;c<4;++c){
          for (int d=0;d<4;++d){
            int abcd=a*4*4*4+b*4*4+c*4+d;
            for (int e=0;e<4;++e){
              int bcde=b*4*4*4+c*4*4+d*4+e;
              if(prohibited(b,c,d,e)){
                dp[i][bcde][1]=add(dp[i][bcde][1], dp[i-1][abcd][0]);
                dp[i][bcde][1]=add(dp[i][bcde][1], dp[i-1][abcd][1]);
              }else{
                dp[i][bcde][0]=add(dp[i][bcde][0], dp[i-1][abcd][0]);
                dp[i][bcde][1]=add(dp[i][bcde][1], dp[i-1][abcd][1]);
              }
            }
          }
        }
      }
    }
  }

  ll ans=0;
  for (int i=0;i<256;++i){
    ans=add(ans, dp[N][i][0]);
  }

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

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int  main() {
	int n, i, t = 7;
	cin >> n;
	if (n % 2 == 0 || n % 5 == 0) {
		cout << -1 << endl;
		return 0;
	}
	for (i = 1; i <= n; ++i) {
		if (t % n == 0)break;
		t = t * 10 + 7;
		t %= n;
	}
	if (i == n + 1)cout << -1 << endl;
	else cout << i << endl;
	return 0;
}

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

signed main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 1e+9;

  vector<int> e(n);
  vector<int> w(n);
  if(s[0]=='W') w[0]++;
  else e[0]++;
  for(int i=1; i<n; ++i) {
    char c = s[i];
    if(c=='W') {w[i] = w[i-1] + 1; e[i] = e[i-1]; }
    else {e[i] = e[i-1] + 1; w[i] = w[i-1]; }
  }

  for(int i=0; i<n; ++i) {
    int E, W;
    E = w[i-1];
    if(i==0) E = 0;
    W = e[n-1] - e[i];
    ans = min(ans, E+W);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll &b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll &b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
ll num=1, ans=0, cnt=0, sum=0;

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

  ld R;
  cin >> R;
  cout << setprecision(10) << R*4*asin(1) << '\n';
  return 0;
}

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

using namespace std;

long double P = acos(-1.0);
const int MAXN = 110;

int n;
long double x[MAXN], y[MAXN], ans;

long double solve() {
	long double r = rand();
	long double xn, yn;
	long double xa = 0, ya = 0;
	r /= RAND_MAX;
	r *= P * 2;
	for (int i = 0; i < n; i++) {
		xn = cos(r) * x[i] - sin(r) * y[i];
		yn = sin(r) * x[i] + cos(r) * y[i];
		if (xn >= 0) {
			xa += xn;
			ya += yn;
		}
	}
	return sqrt(xa * xa + ya * ya);
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
	for (int i = 0; i < 10000; i++) ans = max(ans, solve());
	cout << setprecision(13) << ans;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

int main()
{
	string s, t;
	cin >> s >> t;

	string res = "UNRESTORABLE";

	for (int i = s.length() - 1; i >= 0; i--)
	{
		bool b = true;
		for (int j = 0; j < t.length(); j++)
		{
			if (s[i + j] == '?')
			{
				continue;
			}
			else if (s[i + j] == t[j])
			{
				continue;
			}
			else
			{
				b = false;
				break;
			}
		}

		if (b)
		{

			res = "";
			for (int j = 0; j < t.length(); j++)
			{
				s[i + j] = t[j];
			}
			for (int j = 0; j < s.length(); j++)
			{
				if (s[j] == '?')
				{
					s[j] = 'a';
				}
			}
			res = s;
		}
	}
	

	cout << res << endl;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll MIN_INF = -1000000000000;
ll N, M; 

vector<vector<ll > > G;

bool warshall(){
    //中継点に関して
    for(ll reley = 0; reley < N; reley++){
        for(ll from = 0; from < N; from++){
            for(ll to = 0; to < N; to++){
                //大きくなる方を取っていく
                if(G[from][to] < G[from][reley] + G[reley][to]){
                    G[from][to] = G[from][reley] + G[reley][to];
                }
            }

            //s以外でスタートしたときは感がなくて良いので省く
            //もしも独立したグラフが2つあるような入力がされたとき，どっちか片方に
            //無限に増える閉路があったらご検出してしまう
            /*
            if(G[from][from] > 0){
                cout << "inf" << endl;
                return false;
            }
            */
        }
    }

    return true;
}

int main(){

    //頂点数と辺の数
    cin >> N >> M;
    G.assign(N, vector<ll >());
    
    //初期化
    for(ll i = 0; i < N; i++){
        for(ll j = 0; j < N; j++){
            if(i == j){
                //自分から自分へ
                G[i].push_back(0);
            }else{
                G[i].push_back(MIN_INF);
            }
        }       
    }
    //cout << G.size() << " " << G[0].size() << endl;
    //辺入力
    for(ll i = 0; i < M; i++){   
        ll u, v, w;
        cin >> u >> v >> w;
        //適宜揃える
        u--;
        v--;
        //有向か無向かでコメントアウト　多重辺も防止
        G[u][v] = w;
    }

    //実行
    if(warshall() == false){
        return 0;
    }
    
    //どうせ0番目からしかスタートしないので0番目からスタートした時に無限に大きくなるような
    //閉路があるかどうかをチェックする
    if(G[0][0] > 0){
        cout << "inf" << endl;
    }else{
        cout << G[0][N-1] << endl;
    }
    

}

Measured memory_bytes: 10368
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {

	public static class WeightedUnionFind{
	    int[] par; // 親の番号
	    int[] ws;  // 親との重みの差
	    
	    public WeightedUnionFind(int n){
	        par = new int[n];
	        ws  = new int[n];
	        for(int i = 0; i < n; i++){ 
	        	par[i] = -1;
	        	ws[i]  = 0;
	        }
	    }
	    
	    public int find(int x){
	    	if(par[x] < 0){
	    		return x;
	    	}else{
	    		final int parent = find(par[x]);
	    		ws[x] += ws[par[x]];
	    		par[x] = parent;
	    		return parent;
	    	}
	    }
	    
	    public int weight(int x){
	    	find(x);
	    	return ws[x];
	    }
	    
	    public boolean union(int x, int y, int w){ // x <-(w)- y (x + w = y)
	    	w += weight(x);
	    	w -= weight(y);
	        x = find(x);
	        y = find(y);
	        
	        if(x != y){
	            if(par[y] < par[x]) {  // 多い方が根になるようにスワップする.
	                int tmp = x; x = y; y = tmp;
	                w = -w;
	            }
	            par[x] += par[y];
	            par[y] = x;
	            ws[y] = w;
	            
	            return true;
	        }else{
	            return false;
	        }
	    }
	    
	    public boolean same(int x, int y){
	        return find(x) == find(y);
	    }
	    
	    public Integer diff(int x, int y){ // x - y を求める. 比較不能ならnull.
	    	if(!same(x, y)){
	    		return null;
	    	}else{
	    		return this.weight(x) - this.weight(y);
	    	}
	    }
	    
	    public int size(int x){
	        return -par[find(x)];
	    }
	}
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);

		while(true){
			final int n = sc.nextInt();
			final int m = sc.nextInt();
			
			if(n == 0 && m == 0){
				break;
			}
			
			WeightedUnionFind uf = new WeightedUnionFind(n);
			
			for(int i = 0; i < m; i++){
				final String ops = sc.next();
				
				if("?".equals(ops)){
					final int r = sc.nextInt() - 1;
					final int l = sc.nextInt() - 1;
					final Integer ret = uf.diff(r, l);
					System.out.println(ret == null ? "UNKNOWN" : -ret);
				}else{
					final int r = sc.nextInt() - 1;
					final int l = sc.nextInt() - 1;
					final int w = sc.nextInt();
					
					uf.union(r, l, w);
				}
			}
		}
		
		sc.close();
	}
	
	public static class Scanner {
	    private BufferedReader br;
	    private StringTokenizer tok;

	    public Scanner(InputStream is) throws IOException {
	        br = new BufferedReader(new InputStreamReader(is));
	    }

	    private void getLine() throws IOException {
	        while (!hasNext()) { tok = new StringTokenizer(br.readLine()); }
	    }

	    private boolean hasNext() {
	        return tok != null && tok.hasMoreTokens();
	    }

	    public String next() throws IOException {
	        getLine(); return tok.nextToken();
	    }

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

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

typedef long long ll;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)


int main()
{
    optimize();
    long long n;
    cin>> n;
    long long a[n+1]={}, t;
    rep(i, 1, n)
    {
        cin>> t;
        a[t]++;
    }
    rep(i, 1, n+1)
    cout<< a[i]<< endl;
    return 0;
}



Measured memory_bytes: 5152
#include<stdio.h>
#include<string.h>

int main(void)
{
	int n = 0,ans = 0;
	scanf("%d", &n);
	for (int i = 1; i <= 4; i++)
	{
		if (n % 10 == 2)
		{
			ans += 1;
		}
      n /= 10;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}

   


  int main(){
      lint x;
      cin>>x;
      while(1){
          if(primary(x)){
              cout<<x;
              return 0;
          }
          x++;
      }
  }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>

using namespace std;

// M1, M2, M3, ... , Mn-1, Mn
// M[i,j] = 0 if i = j
// M[i,j] = min { M[i,j] = M[i,k] + M[k+1,j] + p_{i-1} * p_k * p_j } where i <= k < j

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

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

    int M[n+1][n+1];
    for (int i = 1; i <= n; ++i) M[i][i] = 0;
    for (int l = 2; l <= n; ++l) {
        for (int i = 1; i <= n - l + 1; ++i) {
            int j = i + l - 1;
            M[i][j] = std::numeric_limits<int>::max();
            for (int k = i; k <= j - 1; ++k) {
                int q = M[i][k] + M[k+1][j] + P[i-1] * P[k] * P[j];
                M[i][j] = min(M[i][j], q);
            }
        }
    }
    cout << M[1][n] << endl;

    return 0;
}

Measured memory_bytes: 3092
n = int(input())
a =[]
a = list(input().split())
for i in range(len(a)):
    a[i] = int(a[i])

if n < 0 or n > 10000:
    pass
else:
    sum = 0
    for i in range(len(a)):
        sum += a[i]
    print(min(a), max(a), sum)

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

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

using namespace std;

typedef long long int ll;

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

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

template<typename T>
void chmax(T &a, T b) {
    a = max(a, b);
}

template<typename T>
void chmin(T &a, T b) {
    a = min(a, b);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    string S;
    cin >> S;
    vector<char> T(q), D(q);
    REP(i, 0, q) {
        cin >> T[i] >> D[i];
    }

    auto bin1 = [&]() {
        int l = 0, r = n - 1;
        int ans = n;
        while (l <= r) {
            int mid = (l + r) / 2;
            int x = mid;
            bool ok = true;
            REP(i, 0, q) {
                if (S[x] == T[i]) {
                    x += (2 * (D[i] == 'R') - 1);
                }
                if (x < 0) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                r = mid - 1;
                ans = mid;
            } else {
                l = mid + 1;
            }
        }
        return ans;
    };

    auto bin2 = [&]() {
        int l = 0, r = n - 1;
        int ans = -1;
        while (l <= r) {
            int mid = (l + r) / 2;
            int x = mid;
            bool ok = true;
            REP(i, 0, q) {
                if (S[x] == T[i]) {
                    x += (2 * (D[i] == 'R') - 1);
                }
                if (x >= n) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                l = mid + 1;
                ans = mid;
            } else {
                r = mid - 1;
            }
        }
        return ans;
    };

    dump(bin2());
    dump(bin1());

    cout << max(0, bin2() - bin1() + 1) << endl;

    return 0;
}


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

int main(){
  string S;
  cin >> S;
  int N = S.size();
  int ans =999;
  for(int i=0;i<=N-3;++i){
    int num = (S[i] - '0')*100 +(S[i+1] - '0')*10 + (S[i+2] - '0');
    ans = min(ans,abs(num-753));
              }
              cout << ans << endl;
              }


Measured memory_bytes: 256
n = 0
a = []

def format_input(filename = None):
	global n
	global a
	if filename == None:
		n = int(input())
		a = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(2, 2 * 10**5)
		a = [rng(-1 * 10**9, 10**9) for i in range(n)]
		print(n)
		print(' '.join(list(map(str, a))))

def get_answer():
	odd = [0]
	even = [0]
	for i in range(n // 2):
		odd.append(odd[-1] + a[2*i])
		even.append(even[-1] + a[2*i+1])
	if n % 2 == 1:
		odd.append(odd[-1] + a[-1])

	answer = -1 * 10**9 * n
	if n % 2 == 0:
		for i in range(n // 2 + 1):
			answer = max(answer, odd[i] - even[i] + even[-1])
	else:
		even_range = [even[0] - odd[1]]
		for i in range(n // 2):
			add = a[2*i+1] - a[2*i+2]
			min = - a[2*i] + add
			even_range.append(max(even_range[-1] + add, min))
		answer = odd[-1] + max(even_range)
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


Measured memory_bytes: 33760
#include <bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a": " << a << endl;
#define mst(a, b) memset(a, b, sizeof(a))
inline int lowbit(int x) { return x & -x; }
typedef long long LL;
const int N = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int dp[N];
int h[N];

int main() {
#ifdef purple_bro
    freopen("in.txt","r",stdin);
#endif
    int n;

    scanf("%d", &n);

    for (int i = 1; i <= n; i++)
        scanf("%d", &h[i]);

    dp[n - 1] = abs(h[n - 1] - h[n]);

    for (int i = n - 2; i >= 1; i--)
        dp[i] = min(abs(h[i] - h[i + 1]) + dp[i + 1], abs(h[i] - h[i + 2]) + dp[i + 2]);

    printf("%d\n", dp[1]);

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>


using namespace std;



int main() {

	int N, K;
	cin >> N >> K;

	int L[51];
	for (int i = 0; i < N; ++i) cin >> L[i];
	

	sort(L, L + N, greater<int>());
	int total = 0;

	for (int i = 0; i < K; ++i)	total += L[i];
	

	cout << total << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define pii pair<int, int>
#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(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) (c).begin(),(c).end()
#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define PW(n) (1LL<<(n))
using namespace std;
template <class T> inline bool CHMIN(T& a, T b) { if(a>b) { a=b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if(a<b) { a=b; return 1; } return 0; }
template <class T> inline void SORT(T& a) { sort(ALL(a)); }
template <class T> inline void REV(T& a) { reverse(ALL(a)); }
template <class T> inline void UNI(T& a) { SORT(a); a.erase(unique(ALL(a)),a.end()); }
template <class S, class T> ostream& operator<<(ostream& os, const pair<S,T> a) {
  return os << a.first << ' ' << a.second;
}
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N;
int s[110];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N;
  int sum = 0;
  REP(i,N) {
    cin >> s[i];
    sum += s[i];
  }
  if (sum % 10 == 0) {
    sort(s,s+N);
    REP(i,N) {
      if (s[i] % 10 != 0) {
        sum -= s[i];
        break;
      }
      if (i+1 == N) {
        cout << 0 << endl;
        return 0;
      }
    }
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int n,c1=0,c2=0,k;
  scanf("%d",&n);
  int ar[n];
  for(int i=0;i<n;i++)
  {
    scanf("%d",&ar[i]);
  }
  for(int i=0;i<n;i++)
  {
    if((ar[i]==(i+1)))
    {
      c1++;
    }
 else if((ar[i]!=(i+1)))
    {
      c2++;
    }
    
  }
  if((c1==n))
  {
    printf("YES\n");
  }
  else if(c2<=2)
  {
    printf("YES\n");
  }
  else
  {
    printf("NO\n");
  }
  return 0;
  }

Measured memory_bytes: 3164
{$R-,S-,Q-,I-,O+}
const KK=1000;
var cond:array[0..1,1..4*KK,1..4*KK] of longint;
    dp:array[0..1,0..4*KK,0..4*KK] of longint;
    n,k,i,x,y,dx,dy,col,row_sum,max,temp:longint;
    c,d:char;

function sum(col,x1,y1,x2,y2:longint):longint;
begin
  sum:=dp[col,x2,y2]+dp[col,x1-1,y1-1]
        -dp[col,x2,y1-1]-dp[col,x1-1,y2];
end;

begin
  readln(n,k);
  for i:=1 to n do begin
    readln(x,y,c,d);
    x:=x mod (2*k);
    y:=y mod (2*k);
    col:=ord(d='W');
    for dx:=0 to 1 do for dy:=0 to 1 do
      inc(cond[col,x+dx*2*k,y+dy*2*k]);
  end;

  for col:=0 to 1 do
    for x:=1 to 4*k do begin
      row_sum:=0;
      for y:=1 to 4*k do begin
        inc(row_sum,cond[col,x,y]);
        dp[col,x,y]:=dp[col,x-1,y]+row_sum;
      end;
    end;

  max:=0;
  for x:=1 to 2*k do for y:=1 to 2*k do begin
    temp:=0;
    inc(temp,sum(0,x+k,y+k,x+2*k-1,y+2*k-1));
    inc(temp,sum(0,x  ,y  ,x+  k-1,y+  k-1));
    inc(temp,sum(1,x+k,y  ,x+2*k-1,y+  k-1));
    inc(temp,sum(1,x  ,y+k,x+  k-1,y+2*k-1));
    if max<temp then max:=temp;
  end;

  writeln(max);
end.


Measured memory_bytes: 250112
#include<iostream>

using namespace std;

int main(){
	int a,b,c,d,count=0;
	cin>>a>>b>>c>>d;
	for(int i=0;i<=100;i++){
		if(a<=i&&i<=b&&c<=i&&i<=d) count++;
	}
	if(count>0) count--;
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 1e3 + 9, M = 20 + 9, OO = (int) 1e9 + 1;
const long long MOD = 1e9 + 7, INF = 1e18 + 9;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(0);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

void INPUT() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}

int main() {
//	INPUT();
	OUTPUT();
	ll n, m, ans = 2019;
	cin >> n >> m;
	ll x = min(n + 2020, m);
	for (ll i = n; i <= x; i++) {
		for (ll j = i + 1; j <= x; j++) {
			ans = min(ans, (i * j) % 2019);
		}
	}
	cout << ans;

	return 0;

}



Measured memory_bytes: 256
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>

#define DEBUG false

#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
int N ;
char str[26];
std::map<char,int> M ;
/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  int count = 0 ;
  cin >> N ;
  int  n7 ,n4 ;
  int ans = 0;
  if(N%4==0 || N%7 ==0 ||N%11 == 0){
    cout << "Yes" << endl;
    return 0 ;
  }else {
    n7 = N ;
    n4 = N ;
    while(n7 > 0 ){
      n7 = n7 -7 ;
      if(n7 > 0 ){
        if(n7%4==0 || n7%7 ==0 ||n7%11 == 0){
          cout << "Yes" << endl;
          return 0 ;
        }
      }
    }
    while(n4 > 0 ){
      n4 = n4 -4 ;
      if(n4 > 0 ){
        if(n4%4==0 || n4%7 ==0 ||n4%11 == 0){
          cout << "Yes" << endl;
          return 0 ;
        }
      }
    }
    n7 += 7;
    n4 += 4 ;
    if(n7%4 == 0 ){
      cout << "Yes" << endl;
      return 0 ;
    }

  }
  cout << "No" << endl;

  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}


Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    s = list(str(input().rstrip('\n')))
    for i in range(len(s)):
        if k - 1 == i:
            s[i] = s[i].lower()
    print("".join(s))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include <iostream>
#include <cmath>

int main(){
    long d, n;
    std::cin >> d >> n;

    if(n < 100){
        std::cout << (long)std::pow(100, d) * n << std::endl;
    }else{
        std::cout << (long)std::pow(100, d) * (n + 1) << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
# ワーシャルフロイド
def warshall_floyd(n, d):
    for i in range(n):
        for j in range(n):
            for k in range(n):
                d[j][k] = min(d[j][k], d[j][i] + d[i][k])


H, W = map(int, input().split())

N = 10
d = [None] * N
for i in range(N):
    d[i] = list(map(int, input().split()))
warshall_floyd(N, d)

result = 0
for _ in range(H):
    for i in map(int, input().split()):
        if i == -1:
            continue
        result += d[i][1]
print(result)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}
const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i>n || i < 0) return 0; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){
      ans *=(n+1-j);
      ans /= j;
      ans %= MOD;} }return ans;}

bool visited[200001];

vector< vector<int> > graph(200001);

int check(vector<vector<int>> &graph, int v, int n){
    int ok = 1;
    for(int i = 0; i < graph[v].size(); ++i){
        if(graph[v][i] == n) return ok;
        ok += check(graph, graph[v][i], n);
    }
    return 0;
}

void solve(){
    int n, m; cin >> n >> m;
    for(int i = 1; i <= m; ++i){
        int a, b; cin >> a >> b;
        graph[a].push_back(b);
    }
    for(auto start: graph[1]){
        for(auto second: graph[start]){
            if(second == n){
                cout << "POSSIBLE" << endl;
                return;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

int main(void){
    solve();
    return 0;
}


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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;
typedef vector<unordered_map<lli,lli>> graph;

lli a,b,c;

int main(){
  cin >> a >> b >> c;
  if(c >= a && c <= b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define Int int64_t
    #define dump(x) cout << (x) << endl
    #define fi first
    #define se second
    Int mod = 1e9+7;
    Int INF = 1e18;
    double EPS = 0.00000001;
    //Int mod = 1e6+3;

    int main() {
        int n;
        cin >> n;
        for (int i = 0; i < n; i++) {
            double ax, ay, bx, by, cx, cy, dx, dy;
            cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;
            complex<double> a(ax, ay), b(bx, by), c(cx, cy), d(dx, dy);
            complex<double> ab = b - a, cd = d - c;
            if (real(ab * conj(cd)) == 0) {
                dump(1);
            }
            else if (imag(ab * conj(cd)) == 0) {
                dump(2);
            }
            else {
                dump(0);
            }
        }
        return 0;
    }


Measured memory_bytes: 3224
// header {{{
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <boost/foreach.hpp>
#include <vector>
#include <algorithm>
using namespace std;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}

template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
// }}}

// init {{{
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
// }}}

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

signed main() {


	i64 ans = 0;
	string ANS;
	int A, B, C;

	cin >> A >> B >> C;
	
  	if (A==B && A==C){
    	ANS = "No"; 
    }else{
    	if(B==C || A==C || A==B){
         	ANS = "Yes";
        }else{
        	ANS = "No"; 
        }
    }

	cout << ANS << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++) 
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
const int MAX = 1e9 + 100;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=1e9 + 7;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}

int dp[1005][1005] = {0};
char a[1004][1004];

int__ main() {
	fast;

	int m,n; cin >> m >> n;

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

	dp[0][0] = 1;
	int x = 0;

	while(x < m and a[x][0] != '#') {dp[x][0] = 1; x++;}
	x = 0;
	while(x < n and a[0][x] != '#') {dp[0][x] = 1; x++;}

	for(int i=1;i<m;i++) {
		for(int j=1;j<n;j++) {
			if(a[i][j] == '#') continue;
			dp[i][j] = Mod(dp[i-1][j] + dp[i][j-1]);
		}
	}

	cout << dp[m-1][n-1] << endl;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a[100];
    cin>>n;
    rep(i,n) {
        cin>>a[i];
    }
    ll cnt=0;
    rep(i,n) {
        if (i%2==0&&a[i]%2==1) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3612
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, K;
    scan(N, K);
    auto A = aryread();
    auto F = aryread();
    A.sort();
    F.sort!"b<a"();
    long ok = 1_000_000_000_001;
    long ng = -1;

    long eval(long x)
    {
        long cost;
        foreach (i; 0 .. N)
        {
            if (x < F[i] * A[i])
                cost += max(0, (F[i] * A[i] - x + F[i] - 1) / F[i]);
            cost = min(K + 1, cost);
        }
        return cost;
    }

    // writeln(ok);
    while (1 < ok - ng)
    {
        long m = (ok + ng) / 2;
        long c = eval(m);
        // writefln("%s %s %s %s", ok, ng, m, c);
        if (c <= K)
        {
            ok = m;
        }
        else
        {
            ng = m;
        }
    }
    writeln(ok);
}


Measured memory_bytes: 14176
fun main(args: Array<String>) {
    abc099b()
}

fun abc099b() {
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }

    val diff = b - a

    // X番目の塔の高さは X*(X+1)/2、高さbの塔はb-a番目なので、b=(b-a)*(b-a+1)/2
    val bHeight = diff * (diff + 1) / 2

    val answer = bHeight - b

    println(answer)
}


Measured memory_bytes: 35984
#include <iostream>
using namespace std;
int main(void){
   long long int N,a,b ;
   cin >> N >> a >> b ;
   long long int x[100005] ;
   for(int i=1;i<=N;i++){
        cin >> x[i] ;
   }
   
   long long int ans = 0 ;
   for(int i=1;i<N;i++){
        ans += min(a*(x[i+1]-x[i]),b) ;
   }
   cout << ans ;
    
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> p;
typedef vector<p> vp;
const int INF=1e9;
bool prime[1000005];
int a[3005];
int main(int argc,char const* argv[])
{
  int n;
  cin >> n;
  memset(prime,true,sizeof(prime));
  set<int> st;
  ll ans=0;
  for(int i=0;i<n;i++)
    {
      cin >> a[i];
    }
  for(int i=0;i<n;i++)
    {
      ans+=a[i]-1;
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt=LINF,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
map<char,ll> mp;
string tans;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>s;
    if(Size(s)==26){
        if(s=="zyxwvutsrqponmlkjihgfedcba")Cout(-1);
        else{
            rrrep(i,25,0){
                if(c==1)tans+=s[i];
                else{
                char want;
                d=0;
                if(s[i]!='z'){
                rep(j,26){
                    if(s[i]==alph[j]){
                        d=1;
                    }
                    else if(d){
                        want=alph[j];
                        if(mp[want]==1){
                            tans+=want;
                            c=1;
                            break;
                        }
                    }
                }
                }
                if(c==0)mp[s[i]]=1;
                }
            }
            reverse(all(tans));
            Cout(tans);
        }
    }
    else{
        rep(i,Size(s))mp[s[i]]=1;
        cout<<s;
        rep(i,26){
            if(mp[alph[i]]==0){
                cout<<alph[i]<<"\n";
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
li=list(input())
lis=li.copy()
count1=0
count2=0
for i in range(0,len(li)):
  if li[i]=='P':
      try:
        if li[i+1]!='P':
          count1+=1
          li[i+1]='D'
      except IndexError:
          continue
  elif li[i]=='?':
      li[i]='P'
  else:
      continue
    
for i in range(0,len(lis)):
  if lis[i]=='P':
      try:
        if lis[i+1]!='P':
          count2+=1
          lis[i+1]='D'
      except IndexError:
          continue
  elif lis[i]=='?':
      lis[i]='D'
    
    
  else:
      continue


c=li.count('D')
d=lis.count('D')
a=c+count1
b=d+count2
if a>=b:
  for i in li:
    print(i,end='')
else:
  for i in lis:
      print(i,end='')



Measured memory_bytes: 12220
#include <iostream>

using namespace std;

int main(){
    int a[3];
    int buf;
    cin >> a[0] >> a[1] >> a[2];
    
    for(int i = 0; i < 2; ++i){
        if(a[0] > a[1]){
            buf = a[0];
            a[0] = a[1];
            a[1] = buf;
        }
        if(a[1] > a[2]){
            buf = a[2];
            a[2] = a[1];
            a[1] = buf;
        }
        if(a[0] > a[2]){
            buf = a[0];
            a[0] = a[2];
            a[2] = buf;
        }
    }
    cout << a[0] << " " << a[1] << " " << a[2] << endl;
}



Measured memory_bytes: 3100
#include<stdio.h>

int main()
{
	int r,g,b,k,flag=0;
	scanf("%d %d %d",&r,&g,&b);
	scanf("%d",&k);
	while(g<=r)
	{
		g*=2;
		flag++;
	}
	while(b<=g)
	{
		b*=2;
		flag++; 
	}
	if(flag<=k) printf("Yes\n");
	else printf("No\n");
	
	return 0;
 } 

Measured memory_bytes: 3136