akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

char s[100010];
int a;

int main(){
	scanf("%s" , s);
	for(int i = 1 ; s[i] != 0 ; ++i){
		if(s[i-1] != s[i]) ++a;
	}
	printf("%d\n" , a);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

ll gcd(ll a, ll b){
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main(){
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll CD = C * D / gcd(C, D);

  ll divC = B / C - (A-1) / C;
  ll divD = B / D - (A-1) / D;
  ll divCD = B / CD - (A-1) / CD;
  ll ans = B - A + 1 - (divC + divD - divCD);

  cout << ans << endl;
  // cout << gcd(C, D) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int a,b,c,d;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    while(a>=0 && c>=0)
    {
        c = c - b;
        if(c<=0)
        {
            printf("Yes");break;
        }
        a = a - d;
        if(a<=0)
        {
            printf("No");break;
        }

    }
    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	string s;
	cin>>s;
	rep(i,0,s.size()){
		if(s[i]-'A'>=0&&s[i]-'A'<3) s[i]+=23;
		else s[i]-=3;
	}
	o(s);
}

Measured memory_bytes: 1180
from math import sqrt

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        dis = sqrt(float(sum([(X[i][c] - X[j][c])**2 for c in range(D)])))
        if float(int(dis)) == dis:
            cnt += 1

print(cnt)
        


Measured memory_bytes: 3064
import java.io.BufferedInputStream;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in));
        int N = scan.nextInt();
        String[] words = new String[N];
        for (int i=0;i<N;i++) words[i] = scan.next();
        Task tsk = new Task();
        System.out.println(tsk.solve(words)?"Yes":"No");
    }

    static class Task{
        public boolean solve(String[] words){
            HashSet<String> visited = new HashSet<>();
            for (int i=0;i<words.length;i++) {
                if (!visited.add(words[i])) return false;
                if (i > 0 && words[i].charAt(0) != words[i-1].charAt(words[i-1].length()-1)) return false;
            }
            return true;
        }
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define N 400007
#define ll long long
const ll mod=1e9+7;
struct str1
{
    int x,v;
}a[N];
struct str2
{
    int l,r;
}p[N];
bool cmp1(str1 a,str1 b)
{
    return a.x<b.x;
}
bool cmp2(str1 a,str1 b)
{
    return a.v<b.v;
}
bool operator <(str2 a,str2 b)
{
    return a.r<b.r||a.r==b.r&&a.l<b.l;
}
ll f[N],s[N];
int pre[N],suf[N],pos[N];
int main()
{
    int n,i,j,x,y;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d%d",&x,&y);
        a[i]={x,y};
    }
    sort(a+1,a+n+1,cmp2);
    for(i=1;i<=n;i++)
        a[i].v=i;
    sort(a+1,a+n+1,cmp1);
    for(i=1;i<=n;i++)
        a[i].x=i;
    pre[1]=a[1].v;
    for(i=2;i<=n;i++)
        pre[i]=max(pre[i-1],a[i].v);
    suf[n]=a[n].v;
    for(i=n-1;i>=1;i--)
        suf[i]=min(suf[i+1],a[i].v);
    for(i=1;i<=n;i++)
        p[i]={suf[i],pre[i]};
    sort(p+1,p+n+1);
    pos[0]=0;
    for(i=1;i<=n;i++)
    {
        pos[i]=pos[i-1];
        while(pos[i]<n&&p[pos[i]+1].r<=i)pos[i]++;
    }
    f[0]=1;
    s[0]=1;
    for(i=1;i<=n;i++)
    {
        int l=p[i].l,r=p[i].r;
        if(l==1)f[i]=s[i-1];
        else f[i]=(s[i-1]-s[pos[l-2]]+mod)%mod;
        s[i]=(s[i-1]+f[i])%mod;
    }
    ll ans=0;
    for(i=1;i<=n;i++)
        if(p[i].r==n)
            ans=(ans+f[i])%mod;
    printf("%lld\n",ans);
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	for (int i = 0;i < n;i++) {
		string s;
		if(i==0)getchar();
		getline(cin, s);
		int a = s.size();

		for (int j = 0;j < 26;j++) {
			for (int k = 0;k < 26;k++) {
				string sa = s;
				for (int l = 0;l < a;l++) {
					if (sa[l] >= 'a'&&sa[l] <= 'z') {
						int b = sa[l] - 97;
						b =( b*j + k)%26;
						b += 97;
						sa[l] = b;
					}
				}
				size_t za = sa.find("that");
				size_t zb = sa.find("this");
				if (za != string::npos || zb != string::npos) {
					s = sa;
					goto finloop;
				}
			}
		}
	finloop:
		cout << s << endl;
	}
	return 0;
}

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

int main(){
    long long int n, p, c, d, ans=1;
    cin >> n >> p;
    for(int i=2; i<=(int)sqrt(p); i++){
        c=0;
        d=p;
        while(d%i==0 && c<n){
            d=d/i;
            c++;
        }
        if(c==n){
            ans=i;
        }
    }
    if(n==1){
        ans = p;
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> V(N);
  for (int i = 0; i < N; i++)
    cin >> V.at(i);
  
  int ac = 0;
  int wa = 0; 
  int tle = 0;
  int re = 0;
  for (int j = 0; j < N; j++) {
    if (V.at(j) == "AC")
      ac++;
    if (V.at(j) == "WA")
      wa++;
    if (V.at(j) == "TLE")
      tle++;
    if (V.at(j) == "RE")
      re++;
  }
  cout << "AC" << " " << 'x' << " " << ac << endl;
  cout << "WA" << " " << 'x' << " " << wa << endl;  
  cout << "TLE" << " " << 'x' << " " << tle << endl;  
  cout << "RE" << " " << 'x' << " " << re << endl;  
}

Measured memory_bytes: 6428
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

void solve()
{
	string a ,  b;
	cin >> a >> b ;

	int n = a.length();
	int cnt = 0;

	loop(i,0, n)
	{
		if(a[i] != b[i])cnt++;
	}

	cout << cnt;
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == 'o') ++counter;
    if (s[1] == 'o') ++counter;
    if (s[2] == 'o') ++counter;
    cout << 700 + counter * 100 << endl;
}

Measured memory_bytes: 256
s=input()
q=int(input())
for i in range(q):
    l = input().split()
    a,b = int(l[1]),int(l[2])
    if l[0]=="print":
        print(s[a:b+1])
    elif l[0]=="reverse":
        s1=s[a:b+1]
        s=s[:a]+s1[::-1]+s[b+1:]
    elif l[0]=="replace":
        s=s[:a]+l[3]+s[b+1:]


Measured memory_bytes: 5616
#include<stdio.h>
#include<iostream>
using namespace std;

int a,b;
int main (){
    cin >> a >> b;
    if( a + b == 15) cout << '+' << endl;
    else if( a * b == 15) cout << '*' << endl;
    else cout << 'x' << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input_tuple() -> (Vec<char>, Vec<char>) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<String> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0].chars().collect(), vec[1].chars().collect())
}

fn main() {
    let (s, t) = input_tuple();
    for c in t {
        print!("{}", c);
    }
    for c in s {
        print!("{}", c);
    }
    println!();
}


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

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

bool a[51][51];

void dfs(ll c,ll n,bool visited[]){
    visited[c]=true;
    for (ll i=0;i<n;i++){
        if (visited[i])continue;
        if (a[c][i]){
            dfs(i,n,visited);
        }
    }
}

int main(){
    ll n,m,ans=0;
    cin >> n >> m;
    for (ll i=0;i<50;i++)fill(a[i],a[i]+50,false);
    for (ll i=0;i<m;i++){
        ll x,y;
        cin >> x >> y;
        a[x-1][y-1]=true;
        a[y-1][x-1]=true;
    }
    bool visited[n];
    for (ll i=0;i<n;i++){
        for (ll j=i;j<n;j++){
            if (a[i][j]){
                a[i][j]=false;
                a[j][i]=false;
                fill(visited,visited+n,false);
                dfs(0,n,visited);
                a[i][j]=true;
                a[j][i]=true;
                for (ll k=0;k<n;k++){
                    if (!visited[k]){
                        ans++;
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  string n;
  cin >> n;
  int b, sum;
  b = 0;
  sum = 0;
  int size = n.length();
  const char* c = n.c_str();
  rep(i,size) {
  b = (int)(c[i] - '0');
    sum = sum + b;
  }
  if(sum%9==0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  //cout << sum << endl;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  string s;
  cin >> s;
  ll sum = 0;
  ll ans = 0;
  rep(i,3){
    if(s[i] == 'R'){
      sum++;
    }else{
      sum = 0;
    }
    chmax(ans,sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

ll mod = 1000000007;

signed main()
{
    int n, m;
    cin >> n >> m;
    map<ll, ll> a;
    rep(i, n)
    {
        int input;
        cin >> input;
        a[input]++;
    }
    map<ll, ll> cb;
    rep(i, m)
    {
        int b, c;
        cin >> b >> c;
        cb[-c] += b;
    }
    while (cb.size() > 0)
    {
        // for (auto &i : a)
        // {
        //     cout << "i:" << i.first << " " << i.second << endl;
        // }
        // for (auto &i : cb)
        // {
        //     cout << "cb:" << i.first << " " << i.second << endl;
        // }

        auto i = *(cb.begin());
        cb.erase(i.first);
        while (a.size() > 0)
        {
            auto j = *(a.begin());
            a.erase(j.first);
            if (j.first < -i.first)
            {
                if (j.second < i.second)
                {
                    a[-i.first] += j.second;
                    cb[i.first] = i.second - j.second;
                }
                else if (j.second == i.second)
                {
                    a[-i.first] += j.second;
                }
                else
                {
                    a[-i.first] += i.second;
                    a[j.first] += j.second - i.second;
                }
                break;
            }
            else
            {
                a[j.first] += j.second;
                break;
            }
        }
    }
    ll ans = 0;
    for (auto &i : a)
    {
        ans += i.first * i.second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15980
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_DISABLE_PERFCRIT_LOCKS
#define POPCNTI(a) __builtin_popcount(a)
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>


#include <bits/stdc++.h>
using namespace  __gnu_pbds; 
using namespace std;

 
// #ifndef _LOCAL_DEFINE
// inline int getchar_unlocked(){return _getchar_nolock();}
// inline void putchar_unlocked(char c) {_putchar_nolock(c);}
// #endif
 
typedef long long ll;  
typedef pair<int,int> pr; 
 
const ll OOl = LLONG_MAX;
const int N = 1e3+1, M = 1e6+1, OO = INT_MAX,OOmem = 0x4f4f4f4f, MOD = 1e9 + 7;

inline void WRITE_CHAR(char c)  {putchar_unlocked(c);}
 
template<typename T> 
inline bool READn (T &result) {
  int minus = 1;
  char ch;
  result=0;
  ch = (char) getchar_unlocked();
  if(ch!='-') while (!isdigit(ch) && ch!=EOF) ch= (char) getchar_unlocked(), minus = (ch == '-'? -1 : minus);
 
  if(ch==EOF) return false;
  while (isdigit(ch))  result = result*10 + (int) (ch - '0'),ch = (char) getchar_unlocked();
  
  result *= minus;
  return ch != '\n';
}
template<typename T>
inline void WRITEn(T x) {
  if (x < 0) {putchar_unlocked('-'); x = -x; }
  char writeBuffer[20], *writePtr = writeBuffer;
  do {
    *writePtr++ = (char)('0' + x % 10);
    x /= 10;
  }
  while (x);
  do  { putchar_unlocked(*--writePtr); }
  while (writePtr > writeBuffer);
}
inline bool Read_CHAR(char &c)
{
  char READ_CHARACTER = (char)getchar_unlocked();
  while ((READ_CHARACTER == '\n' || READ_CHARACTER == '\t' || READ_CHARACTER == ' ')) READ_CHARACTER = (char)getchar_unlocked();
  if(READ_CHARACTER == EOF) return false;
  c = READ_CHARACTER;
  return true;
} 
inline bool READ_CHAR_ARRAY(char (&x)[N]) {
  char READ_CHARACTER = (char)getchar_unlocked();
  while ((READ_CHARACTER == '\n' || READ_CHARACTER == '\t' || READ_CHARACTER == ' ')) READ_CHARACTER = (char)getchar_unlocked();
  if(READ_CHARACTER == EOF) return false;
  char *ptr = &x[0];
  while ((READ_CHARACTER != '\n' && READ_CHARACTER != '\t' && READ_CHARACTER != ' ' && READ_CHARACTER != EOF)) *ptr++ = READ_CHARACTER, READ_CHARACTER = (char)getchar_unlocked();
  *ptr = '\0';
  return true;
}
inline void WRITE_CHAR_ARRAY(const char *x) {
  while(*x != '\0')
    putchar_unlocked(*x++);
}
int add(int x,int y)
{
  int ret = x+y;
  if(ret>MOD) ret-=MOD;
  return ret;
}
char grid[1001][1001];
int dp[1001][1001];
int main()
{
  
  int h,w;
  READn(h),READn(w);
  for(int i=0;i<h;++i) READ_CHAR_ARRAY(grid[i]);

  dp[0][0]=1;
  for(int i=0;i<h;++i)
  {
    for(int j=0;j<w;++j)
    {
      if(grid[i][j]!='.') continue;
      if(i-1>=0 && grid[i-1][j]=='.') dp[i][j]=add(dp[i][j],dp[i-1][j]);
      if(j-1>=0 && grid[i][j-1]=='.') dp[i][j]=add(dp[i][j],dp[i][j-1]);
    }
  }
  WRITEn(dp[h-1][w-1]);
  return 0;
}




Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll dp[1<<15][16];
ll x[15],y[15];
ll p[15];
ll cst[1<<15];
ll ncst[1<<15];

ll labs(ll val){
	if(val<0LL)return -val;
	return val;
}

ll C(ll xx,ll bit,bool flag){
	ll res=0;
	for(int i=0;i<n;i++){
		if((bit>>i)&1){
			if(!flag){
				res+=labs(x[i]-xx)*p[i];
			}else{
				res+=labs(y[i]-xx)*p[i];
			}
		}
	}
	return res;
}

ll solve(ll bit){
	ll lx=-10001,rx=10001;
	while(lx+5<rx){
		ll mid=(lx+rx)/2;
		if(C(mid,bit,false)<C(mid+1,bit,false)){
			rx=mid+1;
		}else{
			lx=mid;
		}
	}

	ll ly=-10001,ry=10001;
	while(ly+5<ry){
		ll mid=(ly+ry)/2;
		if(C(mid,bit,true)<C(mid+1,bit,true)){
			ry=mid+1;
		}else{
			ly=mid;
		}
	}
	ll cst=C(lx,bit,false);
	for(int i=lx;i<=rx;i++){
		cst=min(cst,C(i,bit,false));
	}
	for(int i=ly;i<=ry;i++){
		cst=min(cst,C(i,bit,true));
	}
	return cst;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld%lld%lld",&x[i],&y[i],&p[i]);
		dp[0][0]+=min(labs(x[i]),labs(y[i]))*p[i];
	}
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<=n;j++){
			if(i!=0 || j!=0)dp[i][j]=(1LL<<60);
			if(j<n && ((i>>j) & 1)){
				ncst[i]+=min(labs(x[j]),labs(y[j]))*p[j];
			}
		}
	}
	for(int i=1;i<(1<<n);i++){
		cst[i]=solve(i);
	}
	dp[(1<<n)-1][0]=0;
	for(int i=(1<<n)-1;i>=0;i--){
		for(int j=0;j<n;j++){
			int nxt=(i-1)&i;
			while(nxt!=i){
				int dif=i-nxt;
				dp[nxt][j+1]=min(dp[nxt][j+1],dp[i][j]+cst[dif]);
				nxt=(nxt-1)&i;
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<(1<<n);j++){
			dp[0][i]=min(dp[0][i],dp[j][i]+ncst[j]);
		}
	}
	for(int i=0;i<=n;i++){
		printf("%lld\n",dp[0][i]);
	}
	return 0;
}


Measured memory_bytes: 8408
N, M, K = map(int, input().split())
mod = 998244353

b = str(bin(mod-2))[2:]
blis = []
for _ in range(len(b)):
  if b[-_-1] == '1':
    blis.append(_)

def modinv(a):
  if a == 1:
    return 1
  else:
    res = 1
    n = len(b)
    li = []
    for _ in range(n):
      li.append(a%mod)
      a = a*a%mod
    for item in blis:
      res = res * li[item] %mod
    return res
"""      
inv = [0,1]
for i in range(2, N):
  inv.append((-inv[mod%i]*(mod//i))%mod)
"""
if N == 1:
  print(M)
  exit()

m = [1]
s = 1
for _ in range(N-1):
  s = s*(M-1)%mod
  m.append(s)

ncombi = [1]
c = 1
for k in range(K):
  c = c*(N-1-k)*modinv(k+1)
  c %= mod
  ncombi.append(c)

"""
olis = ncombi
for k in range(N-1):
  nlis = [1]
  for  j in range(len(olis)-1):
    nlis.append(olis[j]+olis[j+1])
  nlis.append(1)
  olis = nlis
  #print(olis)
ncombi = olis
"""
ans = 0
for k in range(K+1):
  ans = ans + m[-k -1]*ncombi[k]
  ans %= mod

ans = ans*M%mod

print(ans)

Measured memory_bytes: 24660
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> height(N);
    for (int i = 0; i < N; ++i) cin >> height[i];
    
    int sum = height[0];
    for (int i = 0; i < N-1; ++i) {
        sum += max(0, height[i+1] - height[i]);
    }
    
    cout << sum << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////



//////////////////////////////////////

int main() {
    
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    if (M1 != M2) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, k; cin >> n >> k;
    vll h(n);
    rep(i, n) cin >> h[i];
    vll dp(1e6, inf);
    dp[0] = 0;
    rep(i, n) {
        for (int _k = 1; _k <= k; _k++) {
            dp[i + _k] = min(dp[i + _k], dp[i] + abs(h[i + _k] - h[i]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 8832
#include<iostream>
#include<cstring>
using namespace std;
char s[10000009];
int main(){
   cin>>s;
   long long sum=0;
   for(int i=0;i<strlen(s);i++)
   sum+=int(s[i]-'0');
if(sum%9==0)
cout<<"Yes";
else {
    cout<<"No";
}
    system("pause");
}

Measured memory_bytes: 3160
<?php
// E
define('WHITE', '1');
define('BLACK', '0');
fscanf(STDIN, '%d %d %d', $h, $w, $k);
for ($i  = 0; $i < $h; $i++) {
    $s[] = trim(fgets(STDIN));
}

for ($i = 0; $i < $h; $i++) {
    for ($j = 0; $j < $w; $j++) {
        $w_sum[$i][$j] = ($w_sum[$i - 1][$j] ?? 0) + ($w_sum[$i][$j - 1] ?? 0) - ($w_sum[$i - 1][$j - 1] ?? 0);
        if ($s[$i][$j] === WHITE) $w_sum[$i][$j]++;
    }
}

$min = $h + $w;
// bit全探索 横方向のカット
for ($i = 0; $i < 2 ** ($h - 1); $i++) {
    $h_cut = [];
    for ($j = 0; $j < $h - 1; $j++) {
        if (($i >> $j) & 1) {
            $h_cut[] = $j;
        }
    }

    // 貪欲 縦方向のカット
    $w_cut = [];
    $flag = true;
    for ($j = 0; $j < $w; $j++) {
        if (cnt_white($j) > $k) {
            if (count($w_cut) > 0 && $w_cut[count($w_cut) - 1] === $j - 1) {
                $flag = false;
                break;
            }
            if ($j === 0) {
                $flag = false;
                break;
            }
            $w_cut[] = $j - 1;
        }
    }
    if ($flag) $min = min(count($h_cut) + count($w_cut), $min);
}

echo $min . PHP_EOL;

// $i番目を縦方向に割った場合に左側1列のそれぞれのチョコのホワイトチョコブロック数の最大値を返す
function cnt_white($i)
{
    global $h, $w_sum, $h_cut, $w_cut;

    $top = -1;
    $max = 0;
    $left = $w_cut[count($w_cut) - 1] ?? -1;
    $right = $i;
    foreach ($h_cut as $bottom) {
        $cnt = $w_sum[$bottom][$right] - ($w_sum[$top][$right] ?? 0) - ($w_sum[$bottom][$left] ?? 0) + ($w_sum[$top][$left] ?? 0);
        $max = max($cnt, $max);
        $top = $bottom;
    }
    $bottom = $h - 1;
    $cnt = $w_sum[$bottom][$right] - ($w_sum[$top][$right] ?? 0) - ($w_sum[$bottom][$left] ?? 0) + ($w_sum[$top][$left] ?? 0);
    $max = max($cnt, $max);

    return $max;
}

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

int main(){
    long int N, a, b;
    cin >> N;
    long int lim = floor(sqrt(N)); //aの上限を設定
    for(a=lim;a>=1;a--){
        if(N%a == 0){
            b = N/a;
            cout << a + b - 2 << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define N 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,x=0,y=0,z=0,ans=1,c,p;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
    {
        c = 0;
        if(a[i] == x)
            c++,p=1;
        if(a[i] == y)
            c++,p=2;
        if(a[i] == z)
            c++,p=3;
        //cout<<x<<" "<<y<<" " <<z<<" "<<c<<" "<<a[i]<<endl;
        ans = (ans*c)%N;
        if(p == 1)
            x++;
        if(p == 2)
            y++;
        if(p == 3)
            z++;

    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	string N;
	cin >> N;
	
	bool allNine=true;
	for(int i=1;i<N.size();i++)
		if(N[i]!='9')
			allNine=false;
	
	int ans=0;
	for(int i=0;i<N.size();i++)
		ans+=(N[i]-'0');
	
	if(allNine)
		ans=max(ans,N[0]-'0'+(int)(N.size()-1)*9);
	else
		ans=max(ans,N[0]-'0'-1+(int)(N.size()-1)*9);
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

	READV(N);
	string A;
	READ(A);
	ll ans=0;
	FORI(i,1,N)
	{
		if(A[i-1]!=A[i])
		{
			ans++;
		}
	}
	ans++;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 512
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;
 
 
int main()
{
	string s;
	cin>>s;
	
	if(s=="ABC")
	cout<<"ARC";
	
	else
	cout<<"ABC";

     
}

Measured memory_bytes: 3620
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };
int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/

vector<int> G[2005];

int dist[2005][2005];

vector<int> bfs(int n, int st) {

	vector<int> d(n + 10, INF);
	queue<int> que;
	que.push(st);
	d[st] = 0;

	while (!que.empty()) {

		int now = que.front();
		que.pop();
		if (d[now] == INF)continue;

		for (auto nxt : G[now]) {

			if (d[nxt] > d[now] + 1) {
				d[nxt] = d[now] + 1;
				que.push(nxt);
			}
		}
	}

	return d;
}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<ll> p(a), q(b), r(c);

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

	for (int i = 0; i < b; i++)
	{
		cin >> q[i];
	}

	for (int i = 0; i < c; i++)
	{
		cin >> r[i];
	}

	sort(p.rbegin(), p.rend());
	sort(q.rbegin(), q.rend());
	sort(r.rbegin(), r.rend());

	priority_queue<ll> M;


	for (int i = 0; i < x; i++)
	{
		M.push(p[i]);
	}

	for (int i = 0; i < y; i++)
	{
		M.push(q[i]);
	}

	for (int i = 0; i < c; i++)
	{
		M.push(r[i]);
	}

	ll ans = 0;

	ll cnt = 0;
	while (!M.empty()) {

		ans += M.top();
		M.pop();
		cnt++;
		if (cnt == x + y) {
			break;
		}

	}

	cout << ans << endl;





	return 0;
}



Measured memory_bytes: 8944
def dfs(x, y):
    if len(x) == n:
        l.append(x)
        return
    else:
        for i in range(y, m+1):
            z = list(x)
            z.append(i)
            dfs(z, i)
        return

n, m, q = map(int, input().split())
ans = 0
l = []
dfs([], 1)
A = []
B = []
C = []
D = []
for _ in range(q):
    a, b, c, d = map(int, input().split())
    A.append(a-1)
    B.append(b-1)
    C.append(c)
    D.append(d)
for i in range(len(l)):
    cnt = 0
    for j in range(q):
        if l[i][B[j]]-l[i][A[j]] == C[j]:
            cnt += D[j]
    ans = max(cnt, ans)
print(ans)

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    vector<int> C(N);
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }
    C.erase(unique(all(C)), C.end());
    N = C.size();

    const int mod = 1e9 + 7;
    vector<ll> dp(N + 1);
    vector<ll> Csum(200001);
    dp[0] = 1;
    for (int i = 0; i < N; i++) {
        dp[i + 1] = (Csum[C[i]] + dp[i]) % mod;
        Csum[C[i]] += dp[i];
        Csum[C[i]] %= mod;
    }
    cout << dp[N] % mod << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
const int N=12;
char a[N][N];
int main (){
	int n,m;scanf ("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf ("%s",a[i]+1);
	int cnt=0;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			cnt+=(a[i][j]=='#');
	puts((cnt==n+m-1)?"Possible":"Impossible");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n,x;
    cin >> n >> x;
    int num[n];
    rep(i,n){
        cin >> num[i];
    }
    int cum[n+1]={0};
    rep1(i,n){
        cum[i] = cum[i-1] + num[i-1];
    }
    int res = 0;
    rep(i,n+1){
        if(cum[i] > x) break;
        res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    cout << (n%2==0?n:n*2) << endl;
}


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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAXN { 200010 }, MAXP { 10010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll mod_pow(ll a, ll n, ll p)
{
    ll res = 1, base = a;

    while (n)
    {
        if (n & 1)
            res = (res * base) % p;

        base = (base * base) % p;
        n >>= 1;
    }

    return res;
}

ll inv(ll x, ll p)
{
    return mod_pow(x, p - 2, p);
}

ll solve(int N, int P, const string& s)
{
    map<ll, ll> hs;
    ll r = 0, ans = 0, base = 1;

    hs[0]++;

    if (P == 2 or P == 5)
    {
        for (int i = N - 1; i >= 0; --i)
            if ((s[i] - '0') % P == 0)
                ans += i + 1;

        return ans;
    }

    for (int i = N - 1; i >= 0; --i)
    {
        r = (r + base*(s[i] - '0')) % P;
        ans += hs[r];

        base = (10 * base) % P;
        hs[r]++;
    }

    return ans;
}

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

    int N, P;
    string S;
    cin >> N >> P >> S;

    auto ans = solve(N, P, S);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4176
def main():
    S = input()
    N = len(S)
    output = [0] * N
    last = ''
    x = y = 0
    for i in range(N):
        if S[i] == 'R':
            if last == 'L':
                output[i-y] = (y+1)//2 + x//2
                output[i-y-1] = (x+1)//2 + y//2
                x = y = 0
            x += 1
        else:
            y += 1
        last = S[i]
    else:
        output[i+1-y] = (y+1)//2 + x//2
        output[i-y] = (x+1)//2 + y//2
    print(*output)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 6400
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	char name[101];
	int length,value;
};

struct Data{
	Data(int arg_left,int arg_sum_value){
		left = arg_left;
		sum_value = arg_sum_value;
	}
	bool operator<(const struct Data &arg) const{
		return left > arg.left;
	}

	int left,sum_value;
};

int N;
Info info[100];
char line[201];
int case_number = 1,line_length;


void func(){

	int tmp_length;
	for(int i = 0; i < N; i++){
		scanf("%s %d",info[i].name,&info[i].value);
		for(tmp_length = 0; info[i].name[tmp_length] != '\0'; tmp_length++);
		info[i].length = tmp_length;
	}

	scanf("%s",line);
	for(tmp_length = 0; line[tmp_length] != '\0'; tmp_length++);
	line_length = tmp_length;


	int max_value[line_length+1];
	for(int i = 0; i <= line_length; i++)max_value[i] = 0;

	priority_queue<Data> Q;
	Q.push(Data(0,0));

	bool FLG;

	while(!Q.empty()){

		if(Q.top().left == line_length){
			Q.pop();
		}else if(Q.top().sum_value < max_value[Q.top().left]){
			Q.pop();
		}else{

			for(int i = 0; i < N; i++){
				if(Q.top().left+info[i].length-1 >= line_length)continue;

				FLG = true;
				for(int k = 0; k < info[i].length; k++){
					if(line[Q.top().left+k] != info[i].name[k]){
						FLG = false;
						break;
					}
				}


				if(FLG){
					if(max_value[Q.top().left+info[i].length] < Q.top().sum_value+info[i].value){
						max_value[Q.top().left+info[i].length] = Q.top().sum_value+info[i].value;
						Q.push(Data(Q.top().left+info[i].length,max_value[Q.top().left+info[i].length]));
					}
				}
			}

			Q.pop();
		}
	}

	int digit = max_value[line_length];

	int dp[digit+1];

	for(int i = 1; i <= digit; i++){
		dp[i] = BIG_NUM;
	}

	dp[0] = 0;

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

		FLG = true;
		for(int k = 0; k < N; k++){
			if(k == i)continue;

			if(info[k].value == info[i].value && info[k].length < info[i].length){
				FLG = false;
				break;
			}
		}

		if(!FLG)continue;

		for(int k = info[i].value; k <= digit; k++){
			if(dp[k-info[i].value] != BIG_NUM){
				dp[k] = min(dp[k],dp[k-info[i].value]+info[i].length);
			}
		}
	}

	printf("Case %d: %d\n",case_number,dp[digit]);

	case_number++;
}


int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N, K; cin >> N >> K;
    vector<int> A(N); for (auto &a : A) cin >> a;
    vector<bool> B(1 << N);
    int all = (1 << N) - 1;
    for (int i = 0; i <= all; i++) {
        int sum = 0;
        for (int j = 0; j < N; j++) if (i & (1 << j)) {
            sum += A[j];
        }
        if (sum == K) B[all ^ i] = true;
    }
    for (int i = all; i >= 0; i--) {
        if (B[i]) {
            for (int j = 0; j < N; j++) if (i & (1 << j)) {
                B[i ^ (1 << j)] = true;
            }
        }
    }
    int ans = N;
    for (int i = 0; i <= all; i++) {
        if (!B[i]) {
            ans = min(ans, __builtin_popcount(i));
        }
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
int main(){
    int n;
    cin>>n;
    vector<int64_t> a(n);
    map<int,int64_t> mpu; //a[i]-i の数をつかさどる
    map<int,int64_t> mpd; //j-a[j]の数をつかさどる
    rep(i,n){
        cin>>a[i];
        mpu[a[i]+i]++;
        mpd[i-a[i]]++;
    }
    int64_t ans=0;
    for (auto c:mpu){
        int64_t fig = c.first;
        int64_t cnt = c.second;
        ans += cnt*mpd[fig];
    }
    cout<<ans<<endl;

}

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


int main()
{
    std::string s;
    std::cin >> s;
    std::set<char> set;
    for(int i = 0; i < 4; i++)set.insert(s[i]);
    std::cout << (set.size() == 2 ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long lolong;

inline int input() { int x; scanf("%d", &x); return x; }
inline lolong linput() { lolong x; scanf("%lld", &x); return x; }

const int maxn = 1010;
bool s[maxn][maxn];

int main() {
	int n = input(), m = input(), a = input(), b = input();

	for(int i = 1; i <= n; i ++) {
		for(int j = 1; j <= m; j ++)
			if((i <= b and j <= a) or (i > b and j > a))
				putchar('1');
			else
				putchar('0');
		puts("");
	}
}


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

int main(){
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  int f=0;
  sort(A.begin(), A.end());
  if(A.at(0)==0){
    cout << 0 << endl;
    f=1;
  }
  int64_t Ans=1;
  for(int i=0; i<N; i++){
    if(f==0 && A.at(i)>1000000000000000000/Ans){
      cout << -1 << endl;
      f=1;
    }
    else{
      Ans*=A.at(i);
    }
  }
  if(f==0){
  cout << Ans << endl;
  }  
}

Measured memory_bytes: 4048
n = int(input())

maxp = 10**19 * -1
R = [int(input())]
min_R = R[0]

for i in range(1, n):
    R.append(int(input()))
    maxp = max(maxp, R[i]-min_R)
    min_R = min(min_R, R[i])

print(maxp)


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

int main()
{
    int n;
    cin>>n;
    long long int m,a[n+1],ans=1;
    cin>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        ans=(ans*a[i])/(__gcd(ans,a[i]));
    }   
    int c=1;
    for(int i=1;i<=n;i++)
    {
        long long int h=ans/a[i];
        if(h%2==0)
            c=0;
    }
    long long int fans=(2*m/ans+1)/2;
    fans=fans*c;
    cout<<fans;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
n = int(input())
h = list(map(int,input().split()))
dp = [0]*n
dp[0] = 0 #初期化
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
	dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]) )
print(dp[n-1])

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

using namespace std;

#define KIND first
#define VALUE second
#define MAX_STOPS 101
#define MAX_VALUE 10001

double dp[MAX_STOPS][MAX_VALUE];

int main(){
	int x,y,z; //x:=# of kind of eyes y:= # of stops z:=# of event stops
	
	while(cin >> x >> y >> z){
		if(!(x|y|z)) break;
		vector<int> dice(x);
		pair<int,int> stops[y+1]; //
		
		//initialize
		for(int i=0;i<x;i++){
			cin >> dice[i];
		}
		
		fill((pair<int,int> *)stops, (pair<int,int> *)stops + y + 1, make_pair(0,0));
		
		for(int i=0;i<z;i++){
			int pos,kind,val;
			cin >> pos >> kind >> val;
			stops[pos].KIND = kind;
			stops[pos].VALUE = val;
		}
		
		fill((double *)dp, (double *)dp + MAX_STOPS * MAX_VALUE, 0);
		dp[0][0] = 1;
		for(int i=0;i<y;i++){
			for(int j=0;j<MAX_VALUE;j++){
				if(dp[i][j] == 0) continue;
				for(int k=0;k<x;k++){
					int next = i + dice[k],val;
					if(next >= y) next = y;
					if(stops[next].KIND == 2){ //add+
						dp[next][j + stops[next].VALUE] += dp[i][j] / x;
					}else if(stops[next].KIND == 3){ //sub
						val = j - stops[next].VALUE <= 0?0:j-stops[next].VALUE;
						dp[next][val] += dp[i][j] / x;
					}else if(stops[next].KIND == 1){ //proceed
						next += stops[next].VALUE;
						if(next >= y) next = y;
						dp[next][j] += dp[i][j] / x;
					}else{
						dp[next][j] += dp[i][j] / x;
					}
				}
			}
		}
		double e = 0;
		for(int i=0;i<MAX_VALUE;i++){
			e += i * dp[y][i];
		}
		int ret = e;
		cout << ret << endl;
	}
}

Measured memory_bytes: 8796
N,T = map(int,input().split())
A = [[0,0] for _ in range(N+1)]
for i in range(1,N+1):
    a,b = map(int,input().split())
    A[i][0] = a
    A[i][1] = b

A.sort()

dp = [[0 for _ in range(T+1)] for _ in range(N+1)]
for i in range(1,N+1):
    for j in range(T,0,-1):
        if j < T:
            if j < A[i][0]:
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-A[i][0]]+A[i][1])
        else:
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - 1] + A[i][1])
print (dp[N][T])


Measured memory_bytes: 123992
S = input()
if S == "SUN":
    i = 7
elif S == "MON":
    i = 6
elif S == "TUE":
    i = 5
elif S == "WED":
    i = 4
elif S == "THU":
    i = 3
elif S == "FRI":
    i = 2
else: i = 1
print(i)


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    for (int i = k; i < n; ++i) {
        if (a[i] > a[i-k]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4012
X = int(input())

if 400 <= X <=599:
    print(8)
elif 600 <= X <= 799:
    print(7)
elif 800 <= X <= 999:
    print(6)
elif 1000 <= X <= 1199:
    print(5)
elif 1200 <= X <= 1399:
    print(4)
elif 1400 <= X <= 1599:
    print(3)
elif 1600 <= X <= 1799:
    print(2)
elif 1800 <= X <= 1999:
    print(1)

Measured memory_bytes: 9188