akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n; cin >> n;
	std::priority_queue<std::pair<long, int>> qu;
	for(int i = 0; i < n; i++){
		int a; cin >> a;
		
		qu.push({a, i});
	}
	qu.push({0, n});
	
	std::vector<long> ans(n, 0); long c = 1; int pos = 1e9;
	while(!qu.empty()){
		auto p = qu.top(); qu.pop();
		auto q = qu.top();
		
		pos = std::min(pos, p.second);
		
		long dist = p.first - q.first;
		ans[pos] += dist * c; c++;
	}
	
	for(int i = 0; i < n; i++) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 3440
import java.util.Scanner;

/**
 * @program: leetcode
 * @description:
 * @author: wangtengke
 * @create: 2019-06-16
 **/
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int a = scanner.nextInt();
        if(x<a) System.out.println(0);
        else System.out.println(10);
    }

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (ll i = 0; i < (n); ++i)
const int INF = 100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n,m;
    cin >> n >> m;
    vint v[INF];
    /*
    v[1]: 1とつながっている番号リスト
    v[2]: 2とつながっている番号リスト
    ...
    */
    REP(i,m){
        int x,y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    queue<int > que;
    int went[INF]; // 選んだかどうか記録
    int ans[INF]; // 答え用
    que.push(1);
    FOR(i,2,n+1) went[i] = INF; // 初期化
    while(que.size()){
        int p = que.front();
        que.pop();
        for(auto vv : v[p]){ // queの先頭と繋がる番号
            if(went[vv]==INF){
                ans[vv] = p; // ans
                que.push(vv); // あとで見るノード
                went[vv] = 1; // 済みのしるし
            }
        }
    }
    cout << "Yes\n";
    FOR(i,2,n+1) cout << ans[i] << "\n";


    return 0;
}


Measured memory_bytes: 10816
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    while(true){
        cin >>H>>W;
        if(H==0&&W==0)break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout <<"#";
            }
            cout <<endl;
        }
        cout <<endl;
    }
}



Measured memory_bytes: 3068
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[110000];
char str[110000];
int y[110000];
int main(){
	scanf("%s",in);
	int n=strlen(in);
	int ind=0;
	for(int i=0;i<n;i++){
		if(in[i]!='x'){
			y[ind]=i;
			str[ind++]=in[i];
		}
	}
	for(int i=0;i<ind;i++){
		if(str[i]!=str[ind-1-i]){
			printf("-1\n");return 0;
		}
	}
	if(ind==0){
		printf("0\n");return 0;
	}
	int L=0;
	int R=ind-1;
	int ret=0;
	while(L<=R){
		int lm=y[L]-(L?y[L-1]+1:0);
		int rm=((R+1<ind)?y[R+1]-1:n-1)-y[R];
	//	printf("%d %d\n",lm,rm);
		ret+=ABS(lm-rm);
		L++;
		R--;
	}
	printf("%d\n",ret);
}

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

namespace abc156_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var X = CIn.ReadIntArray(N);

      var min = int.MaxValue;

      for (int i = 1; i <= 100; i++)
      {
        var sum = X.Sum(e => (e - i) * (e - i));
        min = Math.Min(min, sum);
      }

      Console.WriteLine(min);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}

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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    long x;
    cin >> n >> x;
    vector<long> l(n), r(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> b[i] >> l[i] >> r[i];
    }

    long s = 0;
    for (int i = 0; i < n; i++) {
        s -= l[i] * b[i];
    }

    long L = -1;
    long R = x * n;

    while (R > L + 1) {
        long M = (L + R) / 2;
        vector<pair<long, int>> z(n);
        for (int i = 0; i < n; i++) {
            z[i] = {x * r[i] - (r[i] - l[i]) * b[i], i};
        }
        sort(z.begin(), z.end());
        int full = M / x;
        int rest = M % x;
        long ss = s;
        vector<bool> tk(n);
        for (int i = n - full; i < n; i++) {
            ss += z[i].first;
            tk[z[i].second] = true;
        }
        bool ok = false;
        for (int i = 0; i < n; i++) {
            long sss;
            if (!tk[i]) {
                sss = ss + max(
                        rest * l[i],
                        rest * r[i] - (r[i] - l[i]) * b[i]);
            } else {
                int p = z[n - full - 1].second;
                sss = ss - (x * r[i] - (r[i] - l[i]) * b[i]) +
                        (x * r[p] - (r[p] - l[p]) * b[p])
                        + max(
                        rest * l[i],
                        rest * r[i] - (r[i] - l[i]) * b[i]);
            }
            if (sss >= 0) {
                ok = true;
            }
        }
        if (ok) {
            R = M;
        } else {
            L = M;
        }
    }
    cout << R;

    return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>

#define ll unsigned long long
#define p(a, b) pair<a,b>

using namespace std;

//ifstream cin("Input.txt");
//ofstream cout("Output.txt");`

int main() {
    int r;
    cin >> r;
    if (r < 1200) {
        cout << "ABC";
    } else if (r < 2800) {
        cout << "ARC";
    } else {
        cout << "AGC";
    }
    return 0;
}


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

const int mod = 1e9 + 7;

int timer, k;
string s;
ll dp[13][2][2][10];
int seen[13][2][2][10];

ll solve(int idx = 0, bool top = 0, bool put = 0, int last = 0) {
	if (idx == (int)s.size()) return put;

	if (seen[idx][top][put][last] == timer)
		return dp[idx][top][put][last];
	seen[idx][top][put][last] = timer;

	ll ans = 0;
	int mx = top ? 9 : s[idx]-'0';
	if (put==0) {
		for (int i = 0; i <= mx; ++i) { //10
			ans += solve(idx + 1, top | (i != mx), (i != 0), i);
		}
	} else {
		for (int i = max(0, last-1); i <= min(mx, min(last+1, 9)); ++i) {
			ans += solve(idx + 1, top | (i != mx), 1, i);
		}
	}
	return dp[idx][top][put][last] = ans;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> k;
	
	ll lo = 1, hi = 1e12, ans = 0;
	while (lo <= hi) {
		ll mid = (lo+hi)>>1;
		s = to_string(mid);
		timer++;
		if (solve() >= k) {
			ans = mid;
			hi = mid - 1;
		} else {
			lo = mid + 1;
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3740
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		int[][]A = new int[N][];
		for(var i=0;i<N;i++){
			string[] str2 = Console.ReadLine().Split();
			A[i] = new int[2]{int.Parse(str2[0]),int.Parse(str2[1])};
		}
		Array.Sort(A,(x,y)=>x[0]-y[0]);
		int na = 0;
		var pq = new PriorityQueue<int,int>();
		long ans = 0;
		for(var i=1;i<=M;i++){
			while(true){
				if(na<N && A[na][0]<=i){
					pq.Add(-A[na][1],na);
					na++;
				} else {
					break;
				}
			}
			if(pq.Count>0){
				var kvpair = pq.Dequeue();
				var p = kvpair.Value;
				ans += A[p][1];
			}
		}
		Console.WriteLine(ans);
	}
}

public class PriorityQueue<TKey, TValue>
{
    SortedDictionary<TKey, Queue<TValue>> dict = new SortedDictionary<TKey, Queue<TValue>>();
    int count = 0;
    public int Count
    {
        get
        {
            return count;
        }
    }
    public void Add(TKey key, TValue value)
    {
        if (!dict.ContainsKey(key))
        {
            dict[key] = new Queue<TValue>();
        }
 
        dict[key].Enqueue(value);
        count++;
    }
    public KeyValuePair<TKey, TValue> Dequeue()
    {
        var queue = dict.First();
        if (queue.Value.Count <= 1)
        {
            dict.Remove(queue.Key);
        }
        count--;
        return new KeyValuePair<TKey, TValue>(queue.Key, queue.Value.Dequeue());
    }
}

Measured memory_bytes: 24392
import java.io.*;
import java.util.*;
import static java.lang.System.in;

public class Main {
    int[] s;
    long mod = 1000000000+7;
    String str;
    public static void main(String[] args) throws Exception {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    long solve(){
        // binary search
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int[] a = new int[m];
        int[] keys = new int[m];
        for(int j=0;j<m;j++){
            a[j] = sc.nextInt();
            int b = sc.nextInt(), c;
            for(int i=0;i<b;i++){
                c = sc.nextInt()-1;
                keys[j] |= (1<<c);
            }
        }
        int[] dp = new int[(1<<n)];
        int maxi = Integer.MAX_VALUE;
        Arrays.fill(dp,maxi);
        dp[0] = 0;
        for(int s=0;s<(1<<n);s++){
            if(dp[s]==maxi) continue; // can't be reached from previous records
            for(int i=0;i<m;i++){
                int curKey = keys[i], cost = a[i];
                int target = s | curKey;
                dp[target] = Math.min(dp[target], dp[s]+cost);
            }
        }
        return dp[(1<<n)-1] == maxi?-1:dp[(1<<n)-1];
    }
}



Measured memory_bytes: 31736
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int h[n];
  cin >> h[0];
  int st=0;
  int ans=0;
  for(int i=1;i<n;++i){
    cin >> h[i];
    if(h[i-1]>=h[i]){
      ++st;
    }else{
      if(st>ans){
        ans=st;
      }
      st=0;
    }
  }
  if(st>ans){
    ans=st;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int main(int argc, char const *argv[]) {
    int n, k;
    cin >> n >> k;
    int dp[200000], ar[200000];
    for(int i = 0; i < n; i++) {
        cin >> ar[i];
        dp[i] = 1e9;
    }
    dp[0] = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j <= min(k + i, n); j++) {
            dp[j] = min(dp[j], abs(ar[i] - ar[j]) + dp[i]);
        }
    }
    //for(int i = 0; i < n; i++)cout << dp[i] << endl;
    cout << dp[n - 1] << endl;
}





Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
int main() {
  int k,d=7,ans=0;
  cin>>k;
  for(int i=0;i<k;i++){
    if(d%k==0){
      cout<<i+1;
      return 0;
    }
    d=(d*10+7)%k;
  }
  cout<<-1;
}

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

int main()
{
    long long t,n,m,i,j,k,x=0,y=0,z;
    cin>>n;
    vector<pair<string,long long> >v;
    z=n;
    while(n--){
        string s;
        cin>>s>>m;
        v.push_back({s,m});
    }
    string ss;
    cin>>ss;
    int ok=0;
    for(i=0;i<z;i++){
            if(ok==1){
                x=x+v[i].second;
            }
        if(v[i].first==ss){
            ok=1;
        }

    }
    cout<<x<<endl;
}


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

using namespace std;

int factors[100005][3];
int happiness[100005][3];

int main(){

	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin >> factors[i][j];
		}
	}
	happiness[0][0] = factors[0][0];
	happiness[0][1] = factors[0][1];
	happiness[0][2] = factors[0][2];

	for(int i=1;i<n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(j!=k){
					happiness[i][j] = max(happiness[i][j],factors[i][j]+happiness[i-1][k]);
				}
			}
		}
	}

	cout << max(happiness[n-1][0], max(happiness[n-1][1], happiness[n-1][2]));


}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    ll N;
    cin >> N;
    ll ans = 1;
    FOR(i,1,N+1){
        ans *= i;
        ans %= MOD;
    } 
    cout << ans << endl;
}


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

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  
  if(n*a > b){
    cout << b << endl;
  }else{
    cout << n*a << endl;
  }
  
  
  //test出力
  /*
  cout << "x:" << x << endl;
  */

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
  ll N, K;
  cin >> N >> K;
  ll A[N];
  for(ll i=0;i<N;++i) cin >> A[i];
  sort(A,A+N);
  if(N<=K) {
    cout << 0;
    return 0;
  }
  ll sum = 0;
  for(int j=0;j<N-K;++j) {
    sum += A[j];
  }
  cout << sum;
}


Measured memory_bytes: 1792
"""Minimum cost Sort."""

def make_cycle(A):
    """Return a list which has the minimum element of A and
    switch elements cycles as list.

    A is a list whose elements' type is 'int'.

    Each cycle list has its minimum elements in the first index.
    """
    B = list(A)
    B.sort()
    cycle_list = [B[0]]
    for i, b in enumerate(B):
        if b != None:
            new_cycle = []
            new_cycle.append(b)
            B[i] = None
            si = A.index(b)
            while si != i:
                st = B[si]
                new_cycle.append(st)
                B[si] = None
                si = A.index(st)
            cycle_list.append(new_cycle)
    return cycle_list

def min_sorting_cost(A):
    """Return the minimum cost of sorting A.

    A is a list whose elements' type is 'int'.
    """
    cycles = make_cycle(A)
    min_w = cycles[0]
    cost = 0
    for c in cycles[1:]:
        n = len(c)
        min_cw = c[0]
        dec = (n - 1) * (min_cw - min_w)
        inc = 2 * (min_w + min_cw)
        if dec < inc:
            cost += sum(c) + min_cw * (n - 2)
        else:
            cost += sum(c) + min_cw * (n - 2) - dec + inc
    return cost


n = int(input())

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

ans = min_sorting_cost(A)

print(ans)

Measured memory_bytes: 7816
g = [[-1] * 15 for _ in range(15)]
n = int(input())
for i in range(n):
    m = int(input())
    for j in range(m):
        a, x = map(int, input().split())
        a -= 1
        g[i][a] = x
def count_ones_by_minus(num):
    count = 0
    while num:
        num &= num -1
        count += 1
    return count
ans = 0
for i in range(1 << n):
    d = [0] * n
    for j in range(n):
        if i >> j & 1:
            d[j] = 1
    ok = True
    for j in range(n):
        if d[j]:
            for k in range(n):
                if g[j][k] == -1:
                    continue
                if g[j][k] != d[k]:
                    ok = False
    if ok:
        ans = max(ans, count_ones_by_minus(i))
print(ans)  

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

using namespace std;

stack<char> stk;

long long dp[18][26][26];

int main()
{
    long long n;
    scanf("%lld", &n);
    
    while(n)
    {
        --n;
        stk.push(n%26+'a');
        n /= 26;
    }
    while(!stk.empty()){
        putchar(stk.top());
        stk.pop();
    }
    puts("");
}

Measured memory_bytes: 3664
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Diagnostics;
using System.Reflection.Metadata;
using System.Threading;

namespace AtCoder
{
    class Program
    {

        struct Point
        {
            public int x;
            public int y;

            public Point(int x, int y)
            {

                this.x = x;
                this.y = y;

            }

        }


        const int BiggestMod = 1000000007;

        public static void Main()
        {

            var num = int.Parse(Console.ReadLine());
            Console.WriteLine(10 - (num / 200));

        }

    }

}

Measured memory_bytes: 27532
#include <iostream>
#include <vector>
#include <algorithm>

template <typename T>
int find_cases(T& edges, int N, int i) {
  int c = 0;
  int l0 = edges[i];

  for(int j = i + 1; j < N - 1; j++) {
    int l1 = edges[j];
    if(l0 == l1) continue;

    for(int k = j + 1; k < N; k++) {
      int l2 = edges[k];

      if(l0 == l2 || l1 == l2) continue;

      if(l0 > l1 && l0 > l2 && l1 + l2 > l0) c++;
      else if(l1 > l0 && l1 > l2 && l0 + l2 > l1) c++;
      else if(l2 > l0 && l2 > l1 && l0 + l1 > l2) c++;
    }
  }

  return c;
}

int main() {
  int N, edge, ans = 0;
  std::vector<int> edges;

  std::cin >> N;

  for(int i = 0; i < N; i++) {
    std::cin >> edge;
    edges.push_back(edge);
  }

  for(int i = 0; i < N - 2; i++) {
    ans += find_cases(edges, N, i);
  }

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  string s;
  cin >> s;
  string need = "AKIHABARA";
  int ptr = 0;
  for (int i = 0; i < 9; i++) {
    if (ptr < (int) s.length() && need[i] == s[ptr]) {
      ptr++;
    } else {
      if (need[i] != 'A') {
        puts("NO");
        return 0;
      }
    }
  }
  if (ptr != (int) s.length()) {
    puts("NO");
    return 0;
  }
  puts("YES");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;
     
     
main()
{
  int a, b, c;
  int cnt = 0;
  cin >> a >> b >> c;
  if( a % 2 || b % 2 || c % 2 ) cout << 0 << endl;
  else if( a == b && b == c ) cout << -1 << endl;
  else {
    while( 1 ) {
      if( a % 2 || b % 2 || c % 2 ) break;
      int aa = b / 2 + c / 2, bb = a / 2 + c / 2, cc = a / 2 + b / 2;
      cnt++;
      a = aa; b = bb; c = cc;
    }
     
    cout << cnt << endl;
  }
}


Measured memory_bytes: 256
import itertools, math, collections, sys
input = sys.stdin.readline
H, W, K = [int(_) for _ in input().split()]
A = [input() for _ in range(H)]
for h, w in itertools.product(range(H), range(W)):
    if A[h][w] == 'S':
        break
visited = [['.'] * W for _ in range(H)]
res = K - 1
Q = collections.deque([[h - 1, w, res], [h + 1, w, res], [h, w - 1, res],
                       [h, w + 1, res]])
sH = set([h])
sW = set([w])
while Q:
    h, w, res = Q.popleft()
    if 0 <= h < H and 0 <= w < W and A[h][w] == '.' and visited[h][w] != '#':
        visited[h][w] = '#'
        sH.add(h)
        sW.add(w)
        if res:
            res -= 1
            Q += [[h - 1, w, res], [h + 1, w, res], [h, w - 1, res],
                  [h, w + 1, res]]
print(1 +
      math.ceil(min([min(sH), H - 1 - max(sH),
                     min(sW), W - 1 - max(sW)]) / K))


Measured memory_bytes: 83932
#約数
def make_divisors(n): #約数をリストで返す
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
N = int(input())

count =0
for i in range(1,N+1,2):
    x =make_divisors(i)
    if len(x) ==8:
        count +=1
print(count)

Measured memory_bytes: 9288
#include <bits/stdc++.h>
using namespace std;
constexpr int maxn = 3e5 + 10;
int n, a[maxn];

bool check(int l,int r){
    int mn = INT_MAX, mx = 0;
    for(int i = l; i <= r; i++){
        mn = min(mn, a[i]);
        mx = max(mx, a[i]);
    }
    if(mn < l || mx > r){
        return 1;
    }
    int lasx = 0, lasy = 0;
    for(int i = l; i <= r; i++){
        if(a[i] != i){
            if(a[i] < i){
                if(lasx < a[i]) lasx = a[i];
                else return true;
            }
            else {
                if(lasy < a[i]) lasy = a[i];
                else return true;
            }
        }
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin>>n;
    for(int i = 1; i <= n; i++) cin >>a[i];

    for(int i = 1; i <= n; i++){
        if(a[i] != i){
            int x;
            for(x = i; a[x + 1] == x + 1 && a[x + 2] != x + 2;) x += 2;
            x = min(x,n);
            if(check(i, x)){
                cout<<"No"<<endl;
                exit(0);
            }
            i = x;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

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

    auto ok = [](string t){
        vector<int> res;
        int cpos = t.find("C");
        while(cpos != -1){
            if(cpos>=2 && cpos <= (t.size()-2)){
                res.push_back(cpos);
            }
            
            cpos = t.find("C", cpos + 1);
        }

        if(res.size()==1) return true;
        else return false;
    };

    bool ok2 = true;
    for(int i=0; i<s.size(); i++){
        if(s.at(i)=='A' || s.at(i)=='C') continue;
        if(isupper(s.at(i))){
            ok2 = false;
        }
    }

    if(s.at(0)=='A' && ok(s) && ok2){
        cout << "AC" << endl;
    }
    else cout << "WA" << endl; 

    return 0;
}


Measured memory_bytes: 256
nums = list("0123456789")
res = 0
while True:
    try:
        cc = list(input())
    except:
        break
    s = 0
    t = []
    for c in cc:
        if c in nums:
            t.append(c)
        else:
            if t != []:
                s += int("".join(t))
                t = []
    if t != []:
        s += int("".join(t))
    res += s
print(res)

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

int main() {
  int a,b,c; cin>>a>>b>>c;  
  int flag=0;
  for(int i=1;i<=b;i++){
    if(a*i%b==c){
      flag=1;
      break;
    }
  }
  if(flag==1) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
use std::io;
#[allow(unused_imports)]
use std::cmp;
use std::collections::LinkedList;

fn read_list() -> LinkedList<String> {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    s.split(' ').map(|x| x.to_string()).collect::<LinkedList<String>>()
}

fn pop_parse<T: std::str::FromStr>(list: &mut LinkedList<String>) -> T {
    list.pop_front().expect("").trim().parse::<T>().ok().unwrap()
}

fn main() {
    let x: i64 = pop_parse(&mut read_list());
    let y = (x + 10) / 11;
    let z = if y * 11 - 5 >= x {y * 2 - 1} else {y * 2};
    println!("{}", z);
}


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

int main(){
	int hen[3],n,i,max;
	cin>>n;
	for(i = 0;i < n;i++){
		cin>>hen[0]>>hen[1]>>hen[2];
		sort(hen,hen+3);

		if(pow(hen[2],2) == (pow(hen[0],2)+pow(hen[1],2)))
				cout<<"YES"<<endl;

		else
				cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long

int d = 365;
vector<vector<int>> s(d, vector<int>(26, 0));
vector<int> c(26);

void init() {
    cin >> d;
    for(int i = 0; i < 26; i++) cin >> c[i];
    for(int i = 0; i < d; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    return;
}

ll calc(vector<int> out) {
    ll score = 0;
    vector<ll> last(26, 0);
    for(int i = 0; i < out.size(); i++) {
        last[out[i]] = i+1; // タイプ番号
        for(int j = 0; j < 26; j++) {
            score -= c[j]*((i+1)-last[j]);
        }
        score += s[i][out[i]];
    }
    return score;
}


int main() {
    init();
    vector<int> out;
    ll ans = 0;
    ll tmp = 0;
    ll max_v = -1;
    for(int i = 0; i < d; i++) {
        max_v = 0;
        int best = 0;
        for(int j = 0; j < 26; j++) {
            out.push_back(j);
            tmp = calc(out);
            if(max_v < tmp) {
                max_v = tmp;
                best = j;
            }
            out.pop_back();
        }
        out.push_back(best);
    }
    
    for(int i = 0; i < d; i++) {
        cout << out[i]+1 << endl;
    }
    //cout << max_v << endl;
    return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> namespace mp = boost::multiprecision; //mp::cpp_intで宣言
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
//ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////

void q(ll a){
    if(a<=9)cout<<"00000"<<a;
    else if(a<=99)cout<<"0000"<<a;
    else if(a<=999)cout<<"000"<<a;
    else if(a<=9999)cout<<"00"<<a;
    else if(a<=99999)cout<<"0"<<a;
    else cout<<a;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    
    ll n,m;cin>>n>>m;
    vector<l_l>v[n];
    l_l p[m];
    rep(i,0,m-1){
        ll x;cin>>p[i].first>>x;
        v[p[i].first-1].pb(l_l(x,i));
    }
    rep(i,0,n-1)sort(v[i].begin(),v[i].end());
    rep(i,0,n-1){
        int vs=v[i].size();
        rep(j,0,vs-1){
            p[v[i][j].second].second=j+1;
        }
    }
    rep(i,0,m-1){
        q(p[i].first);
        q(p[i].second);
        cout<<endl;
    }
    
    return 0;
}
//ios::sync_with_stdio(false);cin.tie(0);



Measured memory_bytes: 8576
#include<iostream>
using namespace std;
int main(){
  int n;
  double x,a[6]={};
  
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x;
    if(x<165.0)a[0]++;
    else if(x<170.0)a[1]++;
    else if(x<175.0)a[2]++;
    else if(x<180.0)a[3]++;
    else if(x<185.0)a[4]++;
    else a[5]++;
  }
  for(int i=0;i<6;i++){
    cout << i+1 << ":";
    for(int j=0;a[i]>j;j++){
      cout << "*";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N,K;
  cin >> N >> K;

  int x = 1;
  rep(i,N) x = min(x * 2, x + K);

  cout << x << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll a,b,c,d,e,i,j,k,l;
cin>>a>>b>>c;
e=abs(a-b);
if(e/2>=c)
{
for(i=a;i<a+c;i++)
cout<<i<<endl;
for(i=b-c+1;i<=b;i++)
cout<<i<<endl;
}
else
{
for(i=a;i<=b;i++)
cout<<i<<endl;}

}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        int p = Integer.parseInt(sc.next());
        String t = sc.next();
        int len = t.length();
        int score = 0;
        char[] pattern = new char[len];
        for (int i = 0; i < len; i++) {
            int val = 0;
            char c =t.charAt(i);
            if (i-k>=0 && pattern[i-k] == c) continue;
            if (c == 'r') {
                val = p;
            } else if (c == 's') {
                val = r;
            } else if (c == 'p') {
                val = s;
            }
            pattern[i] = c;
            score+=val;
        }

        System.out.println(score);
    }
}

Measured memory_bytes: 39912
#include<stdio.h>
int min(int a,int b)
{
    if(a<0)
        return b;
    else if(b<0)
        return a;
    else if(a<b)
        return a;
    else
        return b;
}
int main()
{
    int n,ma,mb;
    scanf("%d %d %d",&n,&ma,&mb);
    int a,b,c;
    int i,j,k;
    int dp[402][402];
    for(i=0;i<402;i++)
        for(j=0;j<402;j++)
            dp[i][j]=-1;
    dp[0][0]=0;
    for(k=0;k<n;k++)
    {
        scanf("%d %d %d",&a,&b,&c);
        for(i=401;i>=0;i--)
            for(j=401;j>=0;j--)
                if(dp[i][j]>=0)
                    dp[i+a][j+b]=min(dp[i+a][j+b],dp[i][j]+c);
    }
    int ans=-1;
    for(i=1;i<402;i++)
        for(j=1;j<402;j++)
            if(i*mb==j*ma)
                ans=min(ans,dp[i][j]);
    printf("%d\n",ans);
    return 0;
}

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

using namespace std;

int main(){
    int k;
    cin >> k;
    vector<int64_t> A(k);
    copy_n(istream_iterator<int64_t>(cin), k, A.begin());

    auto check = [&](int64_t n, bool s){
        for (const auto &a: A)
            n = n / a * a;
        return s ? n >= 2 : n <= 2;
    };

    int64_t l = -1, r = 2 + k * 1e9;
    while (r - l > 1){
        auto mid = (l + r) / 2;
        if (check(mid, false))
            l = mid;
        else 
            r = mid;
    }
    auto high = l;
    l = -1, r = 2 + k * 1e9;
    while (r - l > 1){
        auto mid = (l + r) / 2;
        if (check(mid, true))
            r = mid;
        else 
            l = mid;
    }

    auto low = r;
    if (high < low)
        cout << -1 << endl;
    else
        cout << low << " " << high << endl;
}

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

int main() {
  int A,B,K,divisor;
  int count = 0;
  cin >> A >> B >> K;
  for (int i = min(A,B); i > 0 ; i--) {
    if(A % i == 0 && B % i == 0){ //AもBも割り切る整数i
      divisor = i;
      count++;
    }
    if(count == K){
      break;
    }
  }
  cout << divisor << endl;
}


Measured memory_bytes: 256
package main

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

// 組み合わせの数
func main() {
	sc := bufio.NewScanner(os.Stdin)
	s := ""
	for {
		sc.Scan()
		ary := strings.Split(sc.Text(), " ")
		n, _ := strconv.Atoi(ary[0])
		x, _ := strconv.Atoi(ary[1])
		if n == 0 && x == 0 {
			break
		}
		cnt := 0
		for i := 1; i <= n; i++ {
			for j := 1; j <= n; j++ {
				if j <= i {
					continue
				}
				for k := 1; k <= n; k++ {
					if k <= i || k <= j {
						continue
					} else if i+j+k == x {
						cnt++
					}
				}
			}
		}
		s += fmt.Sprintf("%v\n", cnt)
	}
	fmt.Print(s)
}



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

int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  vector<char> v;
  for (int i=0; i<n; i++) {
    if (v.size()&&v[v.size()-1]=='('&&s[i]==')') v.erase(v.end()-1);
    else v.push_back(s[i]);
  }
  int cnt1=0,cnt2=0;
  for (int i=0; i<v.size(); i++) {
    if (v[i]==')') cnt1++;
    else cnt2++;
  }
  for (int i=0; i<cnt1; i++) {
    cout<<'(';
  }
  cout<<s;
  for (int i=0; i<cnt2; i++) {
    cout<<')';
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>

#define rep(i, n) for (i = 0; i < n; ++i)
#define REP(i, m, n) for (i = m, i < n; ++i)

#define INF 1000 * 1000

using namespace std;

int main() {
  int n;
  cin >> n;
  if (n < 1200)
    printf("ABC");
  else
    printf("ARC");
  return 0;
}



Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);
  int[] a; readA(n, a);

  auto c = new int[](10^^5+1);
  foreach (ai; a) c[ai]++;

  auto c1 = 0, c2 = 0;
  foreach (ci; c)
    if (ci%2 == 1) ++c1;
    else if (ci > 0) ++c2;

  writeln(c1+c2-c2%2);
}


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

const int MAXN = 205;

int N;
char s[MAXN][MAXN];

int dist[MAXN];
int bfs(int src){
	memset(dist, -1, sizeof dist);
	queue <int> q;
	
	q.push(src);
	dist[src] = 0;
	
	int r = 1;
	while(!q.empty()){
		int u = q.front();
		q.pop();
		
		r = max(r, dist[u] + 1);
		
		for(int v = 0; v < N; v++)if(s[u][v] == '1'){
			if(dist[v] == dist[u])return -1;
			if(dist[v] == -1){
				dist[v] = dist[u] + 1;
				q.push(v);
			}
		}
	}
	return r;
}
int main(){	
	scanf("%d", &N);
	for(int i = 0; i < N; i++)
		scanf(" %s", s[i]);
	
	int res = -1;
	for(int i = 0; i < N; i++)
		res = max(res, bfs(i));
	printf("%d\n", res);
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h[10]={},w[10]={};
  int s[10]={};
  int x;
  bool flag = true;
  for(int i=0; i<6; i++){
    cin >> h[i] >> w[i];
    if(h[i] > w[i]) swap(h[i],w[i]);
    s[i] = h[i] * w[i];
  }
  sort(h,h+6);
  sort(w,w+6);
  sort(s,s+6);
  /*
  for(int i=0; i<6; i++) cout << h[i] << " ";
  cout << endl;
  for(int i=0; i<6; i++) cout << w[i] << " ";
  */
  // for(int i=0; i<6; i++) cout << s[i] << " ";
  if(h[0]!=h[1] || h[2] != h[3] || h[4] != h[5] && w[0]!=w[1] || w[2] != w[3] || w[4] != w[5]){
    cout << "no" << endl;
    //cout << "hey" << endl;
  }
  else if(h[0] !=h[2] || w[0] != h[4] || w[2] != w[4]) cout << "no" << endl;
  else if(s[0]!=s[1] || s[2] != s[3] || s[4] != s[5]) cout << "no" << endl;
  else cout << "yes" << endl;
  return 0;
}


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

#define ll long long
#define mfor(i,a,b) for(ll i=(a);i<=(b);i++)

ll p = 1e9 + 7LL;

void solve() {
    ll ans = 0;
    ll N, K; cin >> N >> K;
    mfor(k, K, N + 1) {
        ll X = ((k - 1) * k) / 2;
        ll Y = (N * (N + 1)) / 2 - ((N - k) * (N - k + 1)) / 2;
        ll D = (Y - X + 1) % p;
        ans = (ans + D) % p;
    }
    cout << ans << '\n';
}

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

    solve();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define array_input int n;cin>>n;int a[n+1],i;for(i=1;i<=n;i++){cin>>a[i];}
#define array_output for(i=1;i<=n;i++){cout<<a[i]<<" ";}cout<<endl;
#define INF 2147483647
#define long_INF 18446744073709551615
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
const double pi=acos(-1);
const double eps=1e-6;

void read(int &x)
{
    x=0;
	char c=getchar();
    while(c<'0' || c>'9')c=getchar();
    while(c>='0' && c<='9')
	{
        x=x*10+c-'0';
        c=getchar();
    }
}

void write(int x)
{
    if(x==0)
	{
		putchar(48);
		return;
	}
    int len=0,dg[20];
    while(x>0)
	{
		dg[++len]=x%10;
		x/=10;
	}
    for(int i=len;i>=1;i--)
	{
		putchar(dg[i]+48);
	}
}

int main()
{
	string s;
	cin>>s;
	int f1=0,f2=0,f3=0;
	for (int i=0;i<=s.size();i++)
	{
		if (s[i]=='a')
		{
			f1=1;
		}
		if (s[i]=='b')
		{
			f2=1;
		}
		if (s[i]=='c')
		{
			f3=1;
		}
	}
	if (f1==1 && f2==1 && f3==1)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sl set<ll>
#define vs vector<string>
#define vl vector<ll>
#define vi vector<int>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define PI 3.14159265358979323846
#define ll long long
#define ld long double
#define endl "\n"
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repp(i,a,b) for (ll i = (a); i >= (b); i--)
#define rop(i,a,b)  for(ll i=(a); i>(b); i--)
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define tt long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e5+100;


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

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
using namespace std;
int a,b,bj=0;
int main() {
    cin>>a>>b;
    if((!((a+b)%3))||(!(b%3))||(!(a%3)))puts("Possible");
    else puts("Impossible");
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  string s;
  getline(cin,s);
  for(int i=0;i<s.size();i++){
    if(s[i]>='a'&&s[i]<='z')s[i]-='a'-'A';
    else if(s[i]>='A'&&s[i]<='Z')s[i]+='a'-'A';
  }
  cout<<s<<endl;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <ctime>
#include <math.h> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <utility>
#include <functional>
#include <set>
using namespace std;

int main() {
  vector <long long int> arr;
  long long int n , temp , sum = 0;
  cin >> n;
  for(int i = 0 ; i < n; i++){
    cin >> temp;
    arr.push_back(temp);

  }

  for(int i = 0; i < n-1; i++){
  	if (arr[i] > arr[i+1]){
  		sum += arr[i] - arr[i+1];
  		arr[i+1] = arr[i];

  	}

  }

  cout << sum;

  return 0;
}

Measured memory_bytes: 5336
N = int(input())
A = [int(input()) for _ in range(N)]

sum_A = sum(A)
MOD = 998244353

dp1 = [0] * (sum_A + 1)
dp2 = [0] * (sum_A + 1)
dp1[0] = dp2[0] = 1
tmp_sum = 0

for a in A:
    tmp_sum += a
    for i in reversed(range(tmp_sum + 1)):
        if i - a >= 0:
            # R に塗れる場合
            dp1[i] = (dp1[i - a] + dp1[i] * 2) % MOD
            dp2[i] = (dp2[i - a] + dp2[i]) % MOD
        else:
            dp1[i] = (dp1[i] * 2) % MOD
            dp2[i] = dp2[i]


ans = pow(3, N, MOD)
for i in range(sum_A + 1):
    if i * 2 >= sum_A:
        ans = (ans - dp1[i] * 3 + MOD * 3) % MOD
    if i * 2 == sum_A:
        ans = (ans + dp2[i] * 3) % MOD
print(ans)


Measured memory_bytes: 43100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int m = 1e9+7;
int main()
{
ll h,w;
cin>>h>>w;
char a[h][w];
for(int i =0;i<h;i++)
{
	for(int j =0;j<w;j++)
	{
		cin>>a[i][j];
	}
}
int dp[h][w];
for(int i =0;i<h;i++)
{
	for(int j =0;j<w;j++) dp[i][j]=0;
}
if(a[0][0]=='#') dp[0][0]=0;
else dp[0][0]=1;
for(int j=1;j<w;j++)
{
	if(a[0][j]=='#') dp[0][j]=0;
	else dp[0][j]=dp[0][j-1];
}

for(int i=1;i<h;i++)
{
	if(a[i][0]=='#') dp[i][0]=0;
	else dp[i][0]=dp[i-1][0];
}
for(int i =1;i<h;i++)
{
	for(int j =1;j<w;j++)
	{
		if(a[i][j]=='#') dp[i][j]=0;
		else {
			if(a[i-1][j]=='.')
			{
				dp[i][j]+=dp[i-1][j];
			}
			if(a[i][j-1]=='.')
			{
				dp[i][j]+=dp[i][j-1];
			}
			if(a[i-1][j]=='#' && a[i][j-1]=='#') dp[i][j]=0;
			
			dp[i][j]%=m;
		}
	}
}
	cout<<dp[h-1][w-1]<<"\n";   	
}

Measured memory_bytes: 8516
#include<iostream>
using namespace std;
#define int long long
#define MOD (long long)(1e9+7)
#define MAX_V (long long)(1e5*2+200)

long long MAX_VAL, MAX_VAL2,MIN_VAL=0;
long long fac[MAX_V], mmi[MAX_V], temp[MAX_V];

inline void factorial(){
	fac[0] = fac[1] = 1;
	for(long long i = 2; i < MAX_VAL; fac[i]%=MOD,i++)
		fac[i] = fac[i-1]*(i%MOD);
}

inline long long power_mod(long long x, long long n){
	long long ans = 1;
	for(;n;n>>=1,x*=x,ans%=MOD,x%=MOD)
		if(n&1)ans*=x;
	return ans%MOD;
}

inline void modular_multiplicatibe_inverse(){
	mmi[MAX_VAL-1] = power_mod(fac[MAX_VAL-1],MOD-2);
	for(long long i = MAX_VAL-2; i >= 0; mmi[i]%=MOD,i--)
		mmi[i] = mmi[i+1]*((i+1)%MOD);
}

inline long long combination(long long n, long long r){
	return fac[n]*(mmi[r]*mmi[n-r]%MOD)%MOD;
}

signed main(){
	int H, W, A, B, ans = 0;
	cin>>H>>W>>A>>B;
	MAX_VAL = max(W+H-A-2,A+W-1)+10;
	MAX_VAL = max(MAX_VAL,MAX_VAL2)+20;
	
	factorial();
	modular_multiplicatibe_inverse();

	for(int i = B+1; i <= W; ans%=MOD,i++)
		ans += combination(H-A+i-2,H-A-1)*combination(W+A-i-1,A-1)%MOD;
	cout<<ans<<endl;

}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
const ld eps = 1e-4;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d; cin >> d;
    int c[26];
    REP(i,26) cin >> c[i];
    int lsum = 0;
    REP(i,26) lsum += c[i];
    int v[d][26];
    REP(i,d)REP(j,26) cin >> v[i][j];
    V<> sol(d);
    V<> loss(26,0);
    REP(i,d){
        V<pair<ld,ll>> score(26,{0.0,0});
        REP(j,26) score[j] = {v[i][j] + loss[j] + c[j] * eps, j};
        sort(rall(score));
        int r = score[0].second;
        sol[i] = r;
        REP(j,26){
            if(j == r) loss[j] = 0;
            else loss[j] += c[j];
        }
    }
    REP(i,26) loss[i] = 0;
    ll nowres = 0;
    REP(i,d){
        nowres += v[i][sol[i]];
        REP(j,26){
            if(j == sol[i]) loss[j] = 0;
            else loss[j] += c[j];
            nowres -= loss[j];
        }
    }
    int Q = 250000;
    random_device rnd;
    int newi, newsol, old;
    ll newres;
    while(Q--){
        newi = rnd() % 365;
        newsol = rnd() % 26;
        if(sol[newi] == newsol) continue;
        old = sol[newi];
        sol[newi] = newsol;
        REP(i,26) loss[i] = 0;
        newres = 0;
        REP(i,d){
            newres += v[i][sol[i]];
            REP(j,26){
                if(j == sol[i]) loss[j] = 0;
                else loss[j] += c[j];
                newres -= loss[j];
            }
        }
        if(newres <= nowres) sol[newi] = old;
        else nowres = newres;
    }
    REP(i,d) cout << sol[i] + 1 << '\n';
}

Measured memory_bytes: 3700
#include<stdio.h>

int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  if(a>9){
    printf("-1\n");
    return 0;}
  if(b>9){
    printf("-1\n");
    return 0;}
  printf("%d\n",a*b);
  return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int v[MAXN];

void solve(){
	int n;
	int ans = 0;
	scanf("%d%d", &n, &v[0]);
	REP(i, 1, n){
		scanf("%d", &v[i]);
		if (v[i] == v[i - 1]){
			v[i] = -1;
			ans++;
		}
	}
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
o = gets.chomp.split("")
e = gets.chomp.split("") 


if o.size > e.size then
	tmp = ""
	o.size.times do |i|
		if  o.size - 1 == i then
			tmp = "#{tmp}" + "#{o[i]}" 
			puts tmp
			exit
		end
		tmp = "#{tmp}" + "#{o[i]}" + "#{e[i]}"
	end
elsif o.size < e.size then
	e.size.times do |i|
		if e.size - 1 == i then
			tmp = "#{tmp}"  + "#{e[i]}"
			puts tmp
			exit
		end
		tmp = "#{tmp}" + "#{o[i]}" + "#{e[i]}"
	end
else
	o.size.times do |i|
		tmp = "#{tmp}" + "#{o[i]}" + "#{e[i]}"
	end
end

puts tmp




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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


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


auto solve() {
    int T, A;
    cin >> T >> A;
    return (double) T / A;
}


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

//    cout << (solve() ? "Yes" : "No") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
    cout << solve() << endl;
//    solve();

    return 0;
}


Measured memory_bytes: 256