akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N, M;
	cin >> N >> M;
	vector<int>a(N);
	int L = 1, first = 1;
	rep(i, N)
	{
		cin >> a[i];
		L = lcm(L, a[i]);
		first = lcm(first, a[i] / 2);
		if (first > M)
		{
			cout << 0;
			return 0;
		}
	}
	rep(i, N)
	{
		if ((first/ (a[i] / 2)) % 2 == 0)
		{
			cout << 0;
			return 0;
		}
	}
	int ans = (M - first) / L + 1;
	cout << ans;
}

Measured memory_bytes: 1024
package main

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Splitting Pile
	var N int
	fmt.Scanf("%d", &N)

	sc.Split(bufio.ScanWords)
	a := make([]int, N)
	sum := make([]int, N)
	var temp int
	for i := 0; i < N; i++ {
		a[i] = nextInt()
		temp += a[i]
		sum[i] = temp
	}

	var x, abs int
	var ans int = 100000000000
	for i := 0; i < N-1; i++ {
		x = sum[i]
		abs = int(math.Abs(float64(sum[N-1] - 2*x)))
		if ans > abs {
			ans = abs
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 6060
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	char str[100005];
	int c[100005];
	cin>>n;
	cin>>str;
	int i,j,z=n;
	for(i=0;i<n;i++)
	{
		c[i]=str[i]-'0';
	}
	for(i=0;i<n-1;i++)
	{
		if(c[i]==c[i+1])
		{
			z--;
		}
	}
	cout<<z<<endl;
}

Measured memory_bytes: 768
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N;
	string S;
	cin>>N>>S;
	VI w(N);
	VI e(N);
	if(S[0]=='W'){e[0]=0; w[0]=1;}
	else{e[0]=1;w[0]=0;}
	//cout<<w[0]<<endl;
	FOR(i,1,N){
		if(S[i]=='W'){
			w[i]=w[i-1]+1;
			e[i]=e[i-1];
		}
		else{
			e[i]=e[i-1]+1;
			w[i]=w[i-1];
		}
	}
	int ans=N-w[N-1];
	if(S[0]=='E')ans++;
	//cout<<ans<<endl;
	FOR(i,1,N){
		int x=w[i-1]+e[N-1]-e[i];
		//if(S[i]=='W')x++;
		//cout<<x<<endl;
		ans=min(ans,x);
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 2964
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve(){
  int n;
  cin >> n;
  string s[n];
  std::map<string, int> c;
  for(int i = 0; i < n; i++){
    cin >> s[i];
    c[s[i]]++;
  }
  cout << "AC x " << c["AC"] << endl;
  cout << "WA x " << c["WA"] << endl;
  cout << "TLE x " << c["TLE"] << endl;
  cout << "RE x " << c["RE"] << endl;
   
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  // cin >> t;
  while(t--){
    //tt++;
    //cout << "Case #" << tt << ": ";
    solve();
  }
  return 0;
}  

Measured memory_bytes: 6788
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int>g[300005];
int a[300005];
int ans;
 main()
{
    int n,m;
    cin>>n>>m;
    for(int i =1; i<=n; i++){
        cin>>a[i];
    }
    for(int i =0; i<m; i++){
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i =1; i<=n; i++){
        int flag = 1;
        for(auto j:g[i]){
            if(a[j] >= a[i])flag = 0;
        }
    ans+=(flag && g[i].size() > 0);
    ans+=(g[i].size() == 0);
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 14944
#include<cstdio>
#include<algorithm>
inline long long div_ceil(long long a,long long b){
	return (a+b-1)/b;
}
int main(){
    int n;
    long long t,a,x,y,m;
    scanf("%d%lld%lld",&n,&x,&y);
    for(int i=1;i<n;i++){
        scanf("%lld%lld",&t,&a);
        m=std::max(div_ceil(x,t),div_ceil(y,a));
        x=m*t;
        y=m*a;
    }
    printf("%lld",x+y);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <climits>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(nullptr);
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
//const int mod=1e9+7;
//const int N=1e6+7;

int main(){
    fast;
    int t=1;
    //cin>>t;
    while(t--){
        ll x,y,ans;
        cin>>x>>y;
        if(x==0){
            if(y>=0) ans=y;
            else ans=abs(y)+1;
        }else if(y==0){
            if(x<=0) ans=abs(x);
            else ans=x+1;
        }else if(x>0 and y>0){
            if(x<=y) ans=y-x;
            else ans=x-y+2;
        }else if(x>0 and y<0){
            if(x>=abs(y)) ans=x-abs(y)+1;
            else ans=abs(y)-x+1;
        }else if(x<0 and y>0){
            if(abs(x)<=y) ans=y-abs(x)+1;
            else ans=abs(x)-y+1;
        }else if(x<0 and y<0){
            if(x<=y) ans=y-x;
            else ans=abs(y)-abs(x)+2;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i,n,m;
  m=100000;
  scanf("%d",&n);
  for (i=0;i<n;i++){
    m*=1.05;
    int a=m%1000;
    if (a!=0){
      m+=1000-a;
    }
  }
  printf("%d\n",(int)m);
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n,t; cin >> n >> t;
	vl a(n),b(n);
	rep(i,n) cin >> a[i] >> b[i];
	vvl dp(n+1,vl(t+1,0));
	vvl ep(n+1,vl(t+1,0));
	rep(i,n){
		rep(j,t+1){
			dp[i+1][j] = dp[i][j];
			if(j-a[i] >= 0) chmax(dp[i+1][j],dp[i][j-a[i]]+b[i]);
		}
	}
	ll ans = 0;
	for(ll i=n-1; i>=0; i--){
		rep(j,t){
			chmax(ans,b[i]+dp[i][j]+ep[i+1][t-1-j]);
		}
		/*rep(j,t+1){
			chmax(ans,dp[i][j]+ep[i+1][t-j]);
		}*/
		rep(j,t+1){
			ep[i][j] = ep[i+1][j];
			if(j-a[i] >= 0) chmax(ep[i][j],ep[i+1][j-a[i]]+b[i]);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 141184
A, B, C, X, Y = map(int,input().split())
if 2*C >= A+B:
  print(A*X+B*Y)
  exit()
else:
  answer = min(X, Y)*C*2
  if X >= Y:
    answer += min((X-Y)*A, 2*(X-Y)*C)
  else:
    answer += min((Y-X)*B, 2*(Y-X)*C)
  print(answer)


Measured memory_bytes: 38384
import java.util.*;

class Main{

    int N,P;
    int[] p;

    void solve(){
	Scanner sc = new Scanner(System.in);

	int MAX = 200600;
	p = new int[MAX];
	for(int i=2; i<p.length; i++)p[i] = 1;
	for(int i=2; i<Math.sqrt(MAX)+1; i++){
	    for(int j=i*2; j<MAX; j+=i){
		p[j] = 0;
	    }
	}

	while(true){
	    N = sc.nextInt();
	    P = sc.nextInt();
	    if(N==-1 && P==-1) break;

	    int[] list = new int[20000];
	    Arrays.fill(list,Integer.MAX_VALUE);
	    int idx = 0;
	    for(int i=N+1; i<N+300; i++){
		if(p[i]==0) continue;
		for(int j=i; j<N+300; j++){
		    if(p[j]==0) continue;
		    list[idx] = i+j;
		    idx++;
		}
	    }

	    Arrays.sort(list);

	    System.out.println(list[P-1]);
	}
    }

    public static void main(String[] args){
	new Main().solve();
    }
}

Measured memory_bytes: 13000
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int ans = 0;
        
        for(int i = 1; i <= n; i++){
            int sum = i%10 + (i/10)%10 + (i/100)%10 + (i/1000)%10 + (i/10000)%10;
            if(sum >=a && sum <= b) ans += i;
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b,k;
  cin>>a>>b>>k;
  if(a>k){
    a=a-k;
    k=0;
  }
  else
  {
      k=k-a;
      a=0;
  }
  if(b>k)
  {
      b=b-k;
      k=0;
  }
  else
  {
      k=k-b;
      b=0;
  }
  cout<<a<<" "<<b<<"\n";
  return 0;
}


Measured memory_bytes: 256
while True:
  try:
    n=int(input())
    count=0
    for i in range(10):
      for j in range(10):
        for k in range(10):
          for l in range(10):
            if (i+j+k+l)==n:
              count=count+1
    print(count)
    
  except EOFError:
    break


Measured memory_bytes: 5588
import itertools

N = int(input())
F = []
P = []
for _ in range(N):
    F.append(list(map(int,input().split())))

for i in range(N):
    p = list(map(int,input().split()))
    P.append(p)


ans = -float("inf")

for comb in itertools.product((0,1), repeat=10):
    rieki = 0
    for i in range(N):
        tmp_list = [a + b for a, b in zip(F[i], list(comb))]
        rieki += P[i][tmp_list.count(2)]

    if rieki > ans and sum(comb) != 0:
        ans = rieki

print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue> 
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
int sq[505][505],sum[505][505];
int n,m,q,l,r,tmp,ans;
int main()
{
    scanf("%d",&n);
    for (int i=1; i<=n; i++)
    {
        if (!(i%2)) continue;
        tmp=0;
        for (int j=1; j<=i; j++)
            if (i%j==0) tmp++;
        if (tmp==8) ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
data class Coordinate(val x:Int, val y:Int){
    operator fun plus(other:Coordinate):Coordinate = Coordinate(x + other.x, y + other.y)
    operator fun minus(other:Coordinate):Coordinate = Coordinate(x - other.x, y - other.y)
}
sealed class FourSegmentArea{
    abstract fun find(coordinate:Coordinate):Boolean
    protected abstract fun set(coordinate: Coordinate, size:Int):FourSegmentArea
    protected object Empty:FourSegmentArea() {
        override fun set(coordinate: Coordinate, size:Int): FourSegmentArea = (Area(size) as FourSegmentArea).set(coordinate, size)
        override fun find(coordinate: Coordinate): Boolean = false
    }

    class Area(private val mSize:Int):FourSegmentArea(){
        override fun set(coordinate: Coordinate, size: Int): FourSegmentArea {
            if (size != 1){
                children[coordinate.x / mHalfSize][coordinate.y / mHalfSize] = children[coordinate.x / mHalfSize][coordinate.y / mHalfSize].set(Coordinate(coordinate.x % mHalfSize, coordinate.y % mHalfSize), mHalfSize)
            }
            return this
        }
        private val mHalfSize:Int
            get() = (mSize + 1) / 2
        private var children:Array<Array<FourSegmentArea>> = Array(2){Array(2){Empty as FourSegmentArea}}
        override fun find(coordinate: Coordinate): Boolean {
            return when{
                mSize == 1 -> true
                coordinate.x > mSize || coordinate.y > mSize || coordinate.x < 0 || coordinate.y < 0-> false
                else -> children[coordinate.x / mHalfSize][coordinate.y / mHalfSize].find(Coordinate(coordinate.x % mHalfSize, coordinate.y % mHalfSize))
            }
        }
        fun setAt(coordinate:Coordinate):Unit {
            set(coordinate, mSize)
        }

    }
}
fun main(args:Array<String>):Unit{
    var m = readLine()!!.toInt()
    while(m != 0){
        val area = FourSegmentArea.Area(1000001)
        val target = Array(m){
            val (x, y) = readLine()!!.split(' ').map(String::toInt)
            Coordinate(x, y)
        }
        val stars = Array(readLine()!!.toInt()){
            val (x, y) = readLine()!!.split(' ').map(String::toInt)
            Coordinate(x, y)
        }
        stars.forEach{area.setAt(it)}
        var start = Coordinate(0, 0)
        searching@for(star in stars){
            if (target.map{it + star - target[0]}.all{area.find(it)}){
                start = star - target[0]
                break@searching
            }
        }
        println("${start.x} ${start.y}")
        m = readLine()!!.toInt()
    }
}


Measured memory_bytes: 70908
#include <stdio.h>
#include <unordered_set>
#include <queue>
using namespace std;
struct board{
    int val[3][3];
    int now;
    void in(){
        for(int i=0;i<3;i++)for(int j=0;j<3;j++)scanf("%d",&val[i][j]);
        return ;
    }
};
void swap(int &a,int &b){
    int temp=a;
    a=b;
    b=temp;
    return ;
}
int btoi(board a){
    int ans=0;
    for(int i=0;i<3;i++)for(int j=0;j<3;j++){
        ans*=9;
        ans+=a.val[i][j];
    }
    return ans;
}
int main(){
    unordered_set<int> s;
    queue<board> q;
    board a;
    int temp;
    bool f;
    a.in();
    a.now=0;
    q.push(a);
    s.insert(btoi(a));
    while(!q.empty()){
        a=q.front();
        q.pop();
        f=true;
        for(int i=0;i<3&&f;i++)for(int j=0;j<3&&f;j++)f=a.val[i][j]==(i*3+j+1)%9;
        if(f){
            printf("%d\n",a.now);
            return 0;
        }
        a.now++;
        for(int i=0;i<3;i++)for(int j=0;j<3;j++)if(a.val[i][j]==0){
            if(i!=0){
                swap(a.val[i][j],a.val[i-1][j]);
                temp=btoi(a);
                if(s.find(temp)==s.end()){
                    q.push(a);
                    s.insert(temp);
                }
                swap(a.val[i][j],a.val[i-1][j]);
            }
            if(i!=2){
                swap(a.val[i][j],a.val[i+1][j]);
                temp=btoi(a);
                if(s.find(temp)==s.end()){
                    q.push(a);
                    s.insert(temp);
                }
                swap(a.val[i][j],a.val[i+1][j]);
            }
            if(j!=0){
                swap(a.val[i][j],a.val[i][j-1]);
                temp=btoi(a);
                if(s.find(temp)==s.end()){
                    q.push(a);
                    s.insert(temp);
                }
                swap(a.val[i][j],a.val[i][j-1]);
            }
            if(j!=2){
                swap(a.val[i][j],a.val[i][j+1]);
                temp=btoi(a);
                if(s.find(temp)==s.end()){
                    q.push(a);
                    s.insert(temp);
                }
                swap(a.val[i][j],a.val[i][j+1]);
            }
            break;
        }
    }
}


Measured memory_bytes: 10508
h, w = map(int, input().split())
a = []
for i in range(h):
    wi = input()
    if wi != "."*w:
        a.append(wi)
b = []
for j in range(w):
    wi2 = ""
    for i in range(len(a)):
        wi2 += a[i][w-j-1]
    if wi2 != "."*len(a):
        b.append(wi2)
ans = []
for i in range(len(b[0])):
    hi3 = ""
    for j in range(len(b)):
        hi3 += b[len(b)-j-1][i]
    print(hi3)


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

#define REP(i, a, b) for(int i = (a); i < int(b); ++i)
#define rep(i, n) REP(i, 0, n)

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }

inline int calc(int price, int tax_rate) {
	return price * (100 + tax_rate) / 100;
}

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

	for(int x, y, s; cin >> x >> y >> s && x;) {
		int ans = 0;
		REP(p1, 1, s) {
			REP(p2, p1, s) {
				if(calc(p1, x) + calc(p2, x) == s) {
					chmax(ans, calc(p1, y) + calc(p2, y));
				}
			}
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1192
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

using namespace std;

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

	int s=0;
	int c=0;


	for (int i = 0; i < x.length(); i++) {
		
		if (x[i] == 'S') {
			++s;
		}
		else if(s>0){
			--s;
			++c;
		}
	}

	int ans = x.length() - 2 * c;

	cout << ans << endl;

}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
//#include <pair>
#include <queue>
using namespace std;
//なぜグラフについて勉強するかといえば、グラフが出てくるからだ
#define ll long long
int main(){
    int n;
    cin >>n;
    vector< pair<int,ll> > tree[n+1];
    //make tree
    for(int i=0;i<n-1;i++){
        int a,b,c;
        cin >>a>>b>>c;
        pair<int,ll> nodea(b,c);
        pair<int,ll> nodeb(a,c);
        tree[a].push_back(nodea);
        tree[b].push_back(nodeb);
    }
    int q,k;
    cin >>q>>k;
    vector<ll> cost(n+1,-10000000);
    //calcurate cost
    ll curcost=0;
    int list=0;
    cost[k]=0;
    queue<int> tovisit;
    int from=k;
    tovisit.push(k);
    while(!tovisit.empty()){
        from=tovisit.front();
        tovisit.pop();
        curcost=cost[from];
        for(vector< pair<int,ll> >::iterator to=tree[from].begin();to!=tree[from].end();to++){
            if(cost[ to->first]==-10000000){
                tovisit.push(to->first);
                cost[ to->first]= to->second + curcost;
            }
        }
    }
    //answer
    for(int i=0;i<q;i++){
        int x,y;
        cin >> x>>y;
        ll ans=cost[x]+cost[y];
        cout <<ans<<endl;
    }

    return 0;
}

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


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;



int main() {
    int h,w; cin >> h >> w;
    char field[h][w];
    rep(i,h){rep(j,w){cin >> field[i][j];}}


    int dp[1010][1010];


    //dp[0][0]=1;
    rep(i,w){
        if(field[0][i]=='#'){
            for(int j=i; j<w; j++) dp[0][j]=0;
            break;
        }
        else dp[0][i]=1;
    }
    rep(i,h){
        if(field[i][0]=='#'){
            for(int j=i; j<h; j++) dp[j][0]=0;
            break;
        }
        else dp[i][0]=1;
    }


    rep(i,h-1){
        rep(j,w-1){
            if(field[i+1][j]=='#') dp[i+1][j]=0;
            if(field[i][j+1]=='#') dp[i][j+1]=0;
            dp[i+1][j+1]=(dp[i+1][j]%MOD+dp[i][j+1]%MOD)%MOD;
        }
    }

    COUT(dp[h-1][w-1]);
    cout << endl;

    //rep(i,h){rep(j,w){cout << dp[i][j];}cout << endl;}

}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if ((A < C && C < B)||(B < C && C < A)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<long long,long long>dp;
const long long md=1e9+7;
long long calc(long long x)
{
	if(dp.find(x)!=dp.end())return dp[x];
	if(x==0)return dp[0]=1;
	if(x==1)return dp[1]=2;
	return dp[x]=(calc(x/2)+calc((x-1)/2)+calc((x-2)/2))%md;
}
int main()
{
	long long n;
	scanf("%lld",&n);
	printf("%lld\n",calc(n));
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;
int n,i,a[100004];
long long s,st,dr,m,s1,r,nr,x;
bool ok;
int main()
{
    scanf ("%d", &n);
    s=0LL;
    for (i=1;i<=n;i++)
    {
        scanf ("%d", &a[i]);
        s=0LL+s+a[i];
    }
    nr=(2LL)*s/((1LL)*n*(n+1));
    a[n+1]=a[1];
    if (((2LL)*s%((1LL)*n*(n+1)))==0)
        ok=true;
    else
        ok=false;
    for (i=1;i<=n;i++)
    {
        x=a[i]-a[i+1];
        st=1LL;
        dr=0LL+nr;
        while (st<=dr)
        {
            m=(0LL+st+dr)/2;
            r=(1LL)*m*(n-1)-(nr-m);
            if (r<=x)
                st=0LL+m+1;
            else
                dr=0LL+m-1;
        }
        r=(0LL)+(1LL)*dr*(n-1)-(nr-dr);
        if (r==x)
            s1=0LL+s1+dr;
        else
        {
            ok=false;
            break;
        }
    }
    if (ok==false || s1!=nr)
        printf ("NO\n");
    else
        printf ("YES\n");
    return 0;
}


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl



signed main(){

	string S;
	cin >> S;
	int N = S.length();

	stack<int> st;
	stack<P> ans;

	rep(i, N){
		if (S[i] == '\\') st.push(i);
		else if(st.size()>0 && S[i]=='/'){
			int k = st.top();
			st.pop();
			int tmp = i-k;
			while (ans.size() > 0 && ans.top().first > k){
				tmp += ans.top().second;
				ans.pop();
			}
			ans.push(P(k, tmp));
		}
	}

	vector<int> a;
	int sum = 0;
	while (ans.size() > 0){
		sum += ans.top().second;
		a.push_back(ans.top().second); ans.pop();
	}
	cout << sum << endl;
	if (a.size() == 0){
		cout << a.size();
	}else
		cout << a.size() << " ";
	for (auto i = a.rbegin(); i != a.rend(); i++){
		cout << *i ;
		if (i != a.rend() - 1)
			cout << " ";
	}
	cout << endl;



	return 0;
}



Measured memory_bytes: 3288
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する


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

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

    rep(i, 0, N) {
        cin >> A[i];
        A[i] %= M;
    }
    for (int i = 1; i < N; ++i) {
        A[i] += A[i - 1];
        A[i] %= M;
    }
    map<ll, ll> mp;
    mp[0]++;
    for (auto e : A) mp[e]++;
    ll ans = 0ll;
    for (auto e : mp) {
        if (e.second >= 2) {
            ll es = e.second * 1ll;
            ans += es * (es - 1) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
use proconio::input;
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];

use std::collections::HashSet;
const SIZE: usize = 1_000_000;
fn main() {
    input!(N: usize);
    input!(mut A: [usize; N]);
    let mut flag1 = true;
    let mut flag2 = true;
    let mut w = vec![0; SIZE + 1];
    for &e in &A {
        w[e] += 1;
    }
    let mut check = vec![false; SIZE + 1];
    A.sort();
    for i in 2..=SIZE {
        let mut j = i;
        let mut cnt = 0;
        while j <= SIZE {
            check[j] = true;
            if w[j] > 0 {
                cnt += w[j];
            }
            j += i;
        }

        if cnt > 1 {
            flag1 = false;
            break;
        }
    }

    let mut t = A[0];
    for i in 0..N {
        t = gcd(t, A[i]);
    }
    if t != 1 {
        flag2 = false;
    }
    // println!("{}", t);

    if flag1 {
        println!("pairwise coprime");
    } else if !flag1 && flag2 {
        println!("setwise coprime");
    } else {
        println!("not coprime");
    }
}

fn gcd(a: usize, b: usize) -> usize {
    if b > a {
        gcd(b, a);
    }

    if a % b == 0 {
        return b;
    }

    let r: usize = a % b;

    return gcd(b, r);
}


Measured memory_bytes: 23176
#include<iostream>
using namespace std;
int main(){
    int n,y;
    cin >> n >> y;
    int res10000 = -1, res5000 = -1, res1000 = -1;
    for(int a = 0;a <= n;++a){
        for(int b = 0;b + a <= n;++b){
            int c = n - a - b;
            int total = a * 10000 + b * 5000 + c * 1000;
            if (total == y) {
                res10000 = a;
                res5000 = b;
                res1000 = c;
            }
        }
    }
    cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const ll inf=0x3f3f3f3f;
const int N=100;
struct edge
{
    int v;
    ll s,t;
    int ne;
}e[N<<1];
int n,m,cnt,head[N];
ll s,dis[N],c[N],d[N],dp[N][3000];

void add(int u,int v,ll w,ll t)
{
    e[++cnt]={v,w,t,head[u]};
    head[u]=cnt;
    e[++cnt]={u,w,t,head[v]};
    head[v]=cnt;
}

void bfs()
{
    if(s>=2500) s=2500;
    dp[1][s]=0;
    for(int up=1;up<=n+2;++up){
        for(int i=1;i<=n;++i){
            for(int j=head[i];j;j=e[j].ne){
                for(int now=0;now<=2500;++now){
                    if(now+e[j].s>=0){
                        ///dp[i][now-e[j].s]=min(dp[i][now-e[j].s],dp[e[j].v][now]+e[j].t);
                        dp[i][now]=min(dp[i][now],dp[e[j].v][now+e[j].s]+e[j].t);

                //dp[e[j].v][now-e[j].s]=min(dp[e[j].v][now-e[j].s],dp[i][now]+e[j].t);
                //这样wa
                //dp[e[j].v][now]=min(dp[e[j].v][now],dp[i][now-e[j].s]+e[j].t);
                //这样 样例都过不了
                    }
                }
            }


            for(int now=0;now<=2500;now++){
                if(now-c[i]>=0){
                    dp[i][now]=min(dp[i][now-c[i]]+d[i],dp[i][now]);
                }
            }
        }
    }
}
void solve()
{
   cin>>n>>m>>s;
   //scanf("%d%d%lld",&n,&m,&s);
   mem(dp,inf);
   rep(i,1,m)
   {
       int u,v;ll a,b;
       cin>>u>>v>>a>>b;
       //scanf("%d %d %lld %lld",&u,&v,&a,&b);
       add(u,v,a,b);
   }
   rep(i,1,n) cin>>c[i]>>d[i];
   bfs();
   for(int i=2;i<=n;++i){
        ll ans=1e18;
        for(int now=0;now<=2500;++now) ans=min(ans,dp[i][now]);
        printf("%lld\n",ans);
   }
}
int main()
{
	solve();
}


Measured memory_bytes: 6072
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

int main() {
    string S,T;
    string answer = "";
    vector<string> matcher = vector<string>(4,"");
    matcher[0]="dream";
    matcher[1]="dreamer";
    matcher[2]="erase";
    matcher[3]="eraser";
    T = "";
    queue<string> tmp;
    cin >> S;

    tmp.push(T);

    while(!tmp.empty()){
        T = tmp.front();
        if (T == S){
            answer = "YES";
            break;
        }
        tmp.pop();
        for(int j = 0; j < matcher.size(); j++){
            string calc_tmp = T + matcher[j];
            int tmp_size = calc_tmp.size() -1;
            if (T.size() > S.size()){continue;}
            if(S.compare(0,tmp_size,calc_tmp,0,tmp_size) == 0){
                tmp.push(calc_tmp);
            }
        }
    }

    if (T == S){
        answer = "YES";
    }else{
        answer = "NO";
    }

    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1284
import sys                                                
n = int(sys.stdin.readline())                             
                                                          
xs = []                                                   
for _ in range(n):                                        
  v = [int(x) for x in sys.stdin.readline().split(" ")]   
  xs.append(v)                                            
                                                          
xs.sort(key=lambda x: x[0])                               
if n % 2 == 0:                                            
  m1 = n // 2 - 1                                         
  m2 = m1 + 1                                             
  a1 = xs[m1][0]                                          
  a2 = xs[m2][0]                                          
  xs.sort(key=lambda x: x[1])                             
  b1 = xs[m1][1]                                          
  b2 = xs[m2][1]                                          
  a = (a1 + a2)                                           
  b = (b1 + b2)                                           
  c = (b - a) + 1                                         
  #print(m1, m2, a1, a2, b1, b2, "*", a, b, c)            
  print(c)                                                
else:                                                     
  m = (n + 1) // 2 - 1                                    
  a = xs[m][0]                                            
  xs.sort(key=lambda x: x[1])                             
  b = xs[m][1]                                            
  c = b - a + 1                                           
  #print(m, a, b, c)                                      
  print(c)                                                

Measured memory_bytes: 45348
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue;
        dfs(G, next_v); // 再帰的に探索
    }
}

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a-=1;
        b-=1;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // 全頂点が訪問済みになるまで探索
    int count = 0;
    seen.assign(N, false);
    for (int v = 0; v < N; ++v) {
        if (seen[v]) continue; // v が探索済みだったらスルー
        dfs(G, v); // v が未探索なら v を始点とした DFS を行う
        ++count;
    }
    cout << count-1 << endl;
}

/*
8 5
1 2
3 2
6 5
6 7
8 7
*/


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

int main(){
    int a,b;
    cin>>a>>b;
    if (a+b>=24)
    {
        /* code */
        cout<<a+b-24<<endl;
    }
    else
    {
        cout<<a+b<<endl;
    }
    
    
    }

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void DDCC2019A()
{
	vi m(4);
	m[1] = 300000;
	m[2] = 200000;
	m[3] = 100000;

	int X, Y;
	cin >> X >> Y;
	int sum = 0;
	if (X <= 3)
	{
		sum += m[X];
	}
	if (Y <= 3)
	{
		sum += m[Y];
	}
	if (X * Y == 1)
	{
		sum += 400000;
	}
	cout << sum << endl;
}
int main()
{
	DDCC2019A();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#define _USE_MATH_DEFINES

using namespace std;

int a[3] = {}, maxN = 0, k, s = 0;


int main() {
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
		if (a[i] > a[maxN]) {
			maxN = i;
		}
	}
	cin >> k;

	for (int i = 0; i < k; i++) {
		a[maxN] *= 2;
	}

	for (int i = 0; i < 3; i++) {
		s += a[i];
	}

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
/**************************************
* AUTHOR : SHAKIL MOSHARROF 202014048 *
* NICK : xBCC [2013-2019] C/N:1819    *
* INSTITUTION : MIST CSE 20           *
***************************************/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<float.h>
#define PI 3.14
int main() 
{
	long long a,b,k;
	scanf("%lld %lld %lld",&a,&b,&k);

	
	if (a>=k)
	{
		printf("%lld %lld",(a-k),b);
	}

	else if(a<=k && (a+b)>=k)
	{
		printf("0 %lld",b-(k-a) );;
	}
	else
		printf("0 0");

return 0;
}
/*******************************
* 
*
*
*
*
*
********************************/

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

int count_odd(int n)
{
    int res = 0;
    while (n > 0)
    {
        res++;
        n /= 10;
    }
    return res;
}

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

    int ans = 0;
    rep(i, 1, n + 1)
    if (count_odd(i) % 2 == 1)
        ++ans;

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

Measured memory_bytes: 256
from sys import stdin


def main():
    n = next_int()
    s = next_str()

    maximum_value = 0
    cnt = 0

    for i in range(n):
        cnt += calc(s[i])
        maximum_value = max(maximum_value, cnt)

    print(maximum_value)


def calc(c: chr) -> int:
    if c == 'I':
        return 1
    if c == 'D':
        return -1
    return 0


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <stdio.h>

int BubbleSort(int n, int num[]) {
  int i, j;
  int cnt = 0;
  for (i = 1; i < n; i++) {
    for (j = i; 0 < j; j--) {
      if (num[j] < num[j-1]) {
	int tmp;
	tmp = num[j];
	num[j] = num[j-1];
	num[j-1] = tmp;
	cnt++;
      }
    }
  }
  return cnt;
}

int main() {
  int n;
  int num[100];
  int i;
  int count;

  scanf("%d", &n);

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

  count = BubbleSort(n, num);

  for (i = 0; i < n; i++) {
    printf("%d", num[i]);
    if (i == n-1) break;
    putchar(' ');
  }
  putchar('\n');
  printf("%d\n", count);
  
  return 0;
}



Measured memory_bytes: 2108
n,m = map(int,input().split())
k = []
for i in range(m):
  l = list(map(int,input().split()))
  l.remove(l[0])
  k.append(l)
p = list(map(int,input().split()))
#print(k)
arr = [0]*m
ans = 0
for i in range(2**n):
  flag = 0
  b = str(format(i, '010b'))
  for j in range(m):
    g = int(p[j])
    for h in k[j]:
      g += int(b[10-h])
    if g % 2 == 1:
      flag = 1
      break
  if flag == 0:
    ans += 1
print(ans)

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

using namespace std;

#define pp pair<int, int>
#define ll long long
// copy_n(istream_iterator<int>(cin), n, back_inserter(s));

void solve() {
  ll x;
  cin >> x;
  ll p=100;
  ll t=0;
  while(p<x) {
    ll inc=0.01*p;
    p+=inc;
    t++;
  }
  cout << t;
}

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


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
#define rep(i,N)  for(int i=0;i<N;i++)
int a[4];
int main(){
	int c;
	cin>>c;
	rep(i,4){
		a[3-i]=c%10;
		c/=10;
	}
	rep(i,8){
		c=a[0];
		int b=1;
		rep(j,3){
			if(i&b)
				c+=a[j+1];
			else
				c-=a[j+1];
			b<<=1;
		}
		if(c==7){
			b=1;
			rep(j,3){
				cout<<a[j]<<(i&b?'+':'-');
				b<<=1;
			}
			break;
		}
	}
	cout<<a[3]<<"=7\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,g;
    cin>>n>>g;
    for(int i=2;i<=n;i++)
    {
        int k;
        cin>>k;
        g=__gcd(k,g);
    }
    cout<<g<<endl;
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout << (a+b+1)/2 << endl; 

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define reps(i,n) for(int i=1;i<=(int)n;i++)
#define all(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    if(d == 1){
        cout << "1" << endl;
    }else cout << "0" << endl;
    return 0;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

vector<bool> eratosthenes(int n){
    vector<bool> table(n+1);
    for(int i=0;i<n+1;i++) table[i]=true;
    table[0]=table[1]=false;
    for(int i=2;i*i<=n;i++){
        for(int j=2*i;j<n+1;j+=i){
            table[j]=false;
        }
    }
    return table;
}

int main(){
    int N;
    cin >> N;
    vector<bool> table;
    table = eratosthenes(1010101);
    REP(i,N,1010101){
        if(table[i]){
            P(i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
int aa[N+2],bb[N+2],cc[N+2],dd[N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  string a;cin>>a;int f=0,g=0;
  if(a[0]=='A')f=1;
  if(a[1]=='A')f=1;
  if(a[2]=='A')f=1;

  if(a[0]=='B')g=1;
  if(a[1]=='B')g=1;
  if(a[2]=='B')g=1;

  if(f&g)cout<<"Yes\n";else cout<<"No\n";
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = ""

while N >= 26:
    m = N % 26
    if m == 0:
        ans = chr(96 + 26) + ans
        N //= 26
        N -= 1
    else:
        ans = chr(96 + m) + ans
        N //= 26
# print(ans, N)
if N == 0:
    print(ans)
else:
    print(chr(96 + N) + ans)


Measured memory_bytes: 9176
#include<iostream>
#include<algorithm>
using namespace std;
long dp[3],a;
char op;
int n;
main()
{
	cin>>n>>dp[0];
	dp[1]=dp[2]=-1e18;
	for(int i=1;i<n;i++)
	{
		cin>>op>>a;
		if(op=='+')
		{
			for(int j=0;j<3;j++)dp[j]+=j%2?-a:a;
		}
		else
		{
			dp[2]=max(dp[2]+a,dp[1]+a);
			dp[1]=max(dp[1]+a,dp[0]-a);
			dp[0]-=a;
		}
	}
	cout<<max({dp[0],dp[1],dp[2]})<<endl;
}


Measured memory_bytes: 256
import math


def insertionsort(a, n, g):
    cnt = 0
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j = j - g
            cnt += 1
        a[j + g] = v
    return cnt


def shellsort(a, n):
    g = []
    gap = 1
    while gap <= math.ceil(n / 3):
        g.append(gap)
        gap = 3 * gap + 1
    g = g[::-1]
    m = len(g)
    print(m)
    print(*g)
    cnt = 0
    for i in range(m):
        cnt += insertionsort(a, n, g[i])
    print(cnt)

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
shellsort(a, n)
print("\n".join(map(str, a)))

Measured memory_bytes: 128028
n=int(input())
h = list(map(int, input().split()))
s=list(range(n))
s[n-1]=0
s[n-2]=abs(h[-2]-h[-1])
i=n-3
a=[]
if n!=2:

    while i!=-1:
        a=[abs(h[i]-h[i+1])+s[i+1],abs(h[i]-h[i+2])+s[i+2]]
        s[i]=min(a)
        i-=1

print(s[0])




Measured memory_bytes: 13980
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 10000000007; //10^9+7

int main(){
  int a,b;
  cin>>a>>b;
  if(a*b%2){print("Odd");}
  else {print("Even");}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, begin, end) for(int i=begin;i<end;i++)
#define Rep(i, n) For(i,0,n)
#define Sort(v) sort(v.begin(),v.end())
using namespace std;

vector<int> yakusu(int n){
  vector<int> y0(0);
  int k=1;
  while(k*k<=n){
    if(n%k==0)y0.push_back(k);
    k++;
  }
  vector<int> y=y0;
  for(int i=y0.size()-1;i>=0;i--){
    y.push_back(n/y0[i]);
  }
  return y;
}

int main(){
  int N,M;cin>>N>>M;
  int a=M/N;
  int ans;
  vector<int> y=yakusu(M);
  Rep(i,y.size()){
    if(y[i]<=a)ans=y[i];
  }
  cout<<ans;

  return 0;
}

Measured memory_bytes: 256
group_a = [1,3,5,7,8,10,12]
group_b = [4,6,9,11]
group_c = [2]
judge = 0
num,num_2 = map(int,input().split())
for n in [group_a,group_b,group_c]:
    if num in n and num_2 in n:
        judge += 1

if judge >= 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(1000000)
n, m, q = map(int, input().split())
lst = [list(map(int, input().split())) for i in range(q)]
ans = 0

def dfs(A):
    global ans
    if len(A) == n + 1:
        point = 0
        for i in range(q):
            if A[lst[i][1]] - A[lst[i][0]] == lst[i][2]:
                point += lst[i][3]
                ans = max(ans, point)
        return
    A.append(A[-1])
    while A[-1] <= m:
        dfs(A[:])
        A[-1] += 1

dfs([1])

print(ans)


Measured memory_bytes: 73644
import copy
import sys

# 再帰上限を引き上げる
sys.setrecursionlimit(10**6)

def dfs(graph, v, d):
    seen[v] = True # 訪問済みかどうか
    dist[v] = d # 距離を記録

    # 頂点vから行ける頂点を全探索
    for i in graph[v]:
        if seen[i]:
            continue
        dfs(graph, i, d+1)

# ここから本文
N, u, v = map(int, input().split())

u -= 1
v -= 1

# グラフ構造を作る
graph = [[] for i in range(N)]
for i in range(N - 1):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    graph[A].append(B)
    graph[B].append(A)

# 青木くんからの各頂点の距離
seen = [False for i in range(N)]
dist = [0 for i in range(N)]
dfs(graph, v, 0)
aoki_dist = copy.deepcopy(dist)

# 高橋くんからの各頂点の距離
seen = [False for i in range(N)]
dist = [0 for i in range(N)]
dfs(graph, u, 0)
takahashi_dist = copy.deepcopy(dist)

ans = 0
for i in range(N):
    if aoki_dist[i] > takahashi_dist[i]:
        if aoki_dist[i] - 1 > ans:
            ans = aoki_dist[i] - 1      

print(ans)

Measured memory_bytes: 100632
//#pragma GCC optimize(\"Ofast,no-stack-protector\")
//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx\")
//#pragma GCC target(\"avx,tune=native\")
// Neil

#include<bits/stdc++.h>

using namespace std;

typedef complex<double> base;
typedef long double ld;
typedef long long ll;

#define endl "\n"
#define pb push_back
#define pii pair<int,int>
#define pll pair< ll , ll >
#define vi vector<int>
#define vvi vector< vi >
const int MAXN=(int)(2e5+5);
const ll MOD=(ll)(1e9+7);
int t;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    t = 1;
    while(t--){
        int n;
        cin>>n;
        cout<<(n*(n+1))/2<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#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() {
  int a, b;
  cin >> a >> b;
  int ans = (a + b) % 24;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620