akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int L = sc.nextInt();
		int R = sc.nextInt();
		int d = sc.nextInt();
		int cnt = 0;
		
		for(int i = L; i <= R; i++) {
			if(i % d == 0) {
				cnt += 1;
			}
		}
		System.out.println(cnt);
		sc.close();
	}
}

Measured memory_bytes: 35736
#include <bits/stdc++.h>
using namespace std;
int n, lx, ly, lt;
int main()
{
    cin >> n;
    lx = 0; ly = 0; lt = 0;
    for(int i = 1, x, y, t; i <= n; ++i)
    {
        cin >> t >> x >> y;
        x = abs(x - lx);
        y = abs(y - ly);
        t = t - lt;
        int v = x + y;
        if(x + y <= t && (v % 2) == (t % 2))continue;
        else
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
//DiagonalString.java
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		String s1=sc.next();
        String s2=sc.next();
        String s3=sc.next();
        
        System.out.print(s1.charAt(0));
        System.out.print(s2.charAt(1));
        System.out.print(s3.charAt(2));

        sc.close();
    }
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#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)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 301;
const i64 P = 998244353;
i64 dp[maxn][maxn][maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    string s;
    int K;
    cin >> s >> K;
    reverse(all(s));
    int n1 = 0;
    vi d;
    for (char c: s) {
        if (c == '0') {
            d.pb(n1);
            n1 = 0;
        } else ++n1;
    }
    d.pb(n1);
    vi pd(d.size() + 1);
    partial_sum(all(d), pd.begin() + 1);

    int s1 = pd.back();
    dp[0][0][0] = 1;
    int M = d.size();
    for1(i, M) {
        int D = d[i - 1];
//        cerr << i << ' ' << D << '\n';
        forn(j, maxn) forn(k, maxn) dp[i][j][k] = dp[i - 1][j][k];
        ford(j, maxn - 1) for1(k, maxn - 1) (dp[i][j][k] += dp[i][j + 1][k - 1]) %= P;
        forn(k, maxn) {
            i64 sum = 0;
            forn(j, maxn) {
                (dp[i][j][k] += sum) %= P;
                (sum += dp[i - 1][j][k]) %= P;
                if (j - D >= 0) (sum -= dp[i - 1][j - D][k]) %= P;
                if (sum < 0) sum += P;
            }
        }
//        forn(j, maxn) forn(k, maxn) if (dp[i][j][k]) cerr << i << ' ' << j << ' ' << k << ' ' << dp[i][j][k] << '\n';
    }

    i64 ans = 0;
    forn(k, maxn) if (k <= K) (ans += dp[M][0][k]) %= P;
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 215996
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

typedef vector<ll> vec;
typedef vector<vec> mat;
mat mul(mat &A, mat &B, ll MOD){ // A*B
  mat C(A.size(), vec(B[0].size()));
  rep(i,A.size()) rep(k,B.size()){
    rep(j,B[0].size()){
      __uint128_t a = A[i][k];
      __uint128_t b = B[k][j];
      __uint128_t ab = a*b;
      ab %= MOD;
      
      C[i][j] = (C[i][j]+(ll)ab)%MOD;
    }
  }
  return C;
}
mat pow(mat A, ll n, ll MOD){ // A^n
  mat B(A.size(), vec(A.size()));
  rep(i,A.size()) B[i][i] = 1;
  while(n>0){
    if(n&1) B=mul(B,A,MOD);
    A=mul(A,A,MOD);
    n>>=1;
  }
  return B;
}

ll mod_pow(ll x, ll n, ll mod){
  if(n==0) return 1;
  ll res = mod_pow(x * x % mod, n / 2, mod);
  if(n & 1) res = res * x % mod;
  return res;
}

int get_keta(ll x){
  int keta = 0;
  while(x>0){ keta++; x/=10; }
  return keta;
}


int main(){
  ll L, A, B, M;
  cin >> L >> A >> B >> M;

  ll ret = 0;

  ll base = 0;
  vec mvec{0,A%M,1};
  for(ll k=1; k<19; k++){
    ll st = -1, ed = -1;
    {
      ll lb = -1, ub = L;
      while(ub-lb>1){
        ll mid = (lb+ub)/2;

        ll s = A + B*mid;
        if(get_keta(s) < k) lb = mid;
        else ub = mid;
      }
      if(0<=ub && ub<L){
        if(get_keta(A+B*ub) == k) st = ub;
      }
    }
    {
      ll lb = -1, ub = L;
      while(ub-lb>1){
        ll mid = (lb+ub)/2;

        ll s = A + B*mid;
        if(get_keta(s) <= k) lb = mid;
        else ub = mid;
      }
      if(0<=lb && lb<L){
        if(get_keta(A+B*lb) == k) ed = lb;
      }
    }
    if(st != -1 && ed != -1){
      ll n = ed-st+1;
      ll kk = 1;
      rep(i,k) kk *= 10;
      mat smat{{kk%M,0,0},{1,1,0},{0,B%M,1}};
      mat dmat = pow(smat,n,M);
      //cout << " " << dmat[0][0] << " " << dmat[0][1] << " " << dmat[0][2] << endl;
      //cout << " " << dmat[1][0] << " " << dmat[1][1] << " " << dmat[1][2] << endl;
      //cout << " " << dmat[2][0] << " " << dmat[2][1] << " " << dmat[2][2] << endl;
      vec nvec{0,0,0};
      nvec[0] += (dmat[0][0] * mvec[0])%M;
      nvec[0] %= M;
      nvec[0] += (dmat[1][0] * mvec[1])%M;
      nvec[0] %= M;
      nvec[0] += (dmat[2][0] * mvec[2])%M;
      nvec[0] %= M;
      nvec[1] += (dmat[0][1] * mvec[0])%M;
      nvec[1] %= M;
      nvec[1] += (dmat[1][1] * mvec[1])%M;
      nvec[1] %= M;
      nvec[1] += (dmat[2][1] * mvec[2])%M;
      nvec[1] %= M;
      nvec[2] += (dmat[0][2] * mvec[0])%M;
      nvec[2] %= M;
      nvec[2] += (dmat[1][2] * mvec[1])%M;
      nvec[2] %= M;
      nvec[2] += (dmat[2][2] * mvec[2])%M;
      nvec[2] %= M;
      mvec = nvec;
      //cout << mvec[0] << endl;
    }
  }
  
  cout << mvec[0] << endl;
  
  return 0;
}


Measured memory_bytes: 256
# ABC088D - Grid Repainting
def bfs() -> None:
    dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    q = [(0, 0)]
    while q:
        x, y = q.pop(0)
        for dx, dy in dxy:
            nx, ny = x + dx, y + dy  # next x, y
            # find unsearched grids of S and keep them in the queue
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == "." and D[nx][ny] == 0:
                q.append((nx, ny))
                D[nx][ny] = D[x][y] + 1


def main():
    # shortest path needs to remain white, the rest can be black
    global H, W, S, D
    H, W, *S = open(0).read().split()
    H, W = int(H), int(W)
    D = [[0] * W for _ in range(H)]  # distance from (0, 0) to (x, y)
    D[0][0] = 1
    bfs()
    white, x = sum(s.count(".") for s in S), D[-1][-1]
    ans = white - x if x else -1  # x = 0 <-> can't make a path to goal
    print(ans)


if __name__ == "__main__":
    main()

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

long long GCD(long long a,long long b){
    if(a<b)swap(a,b);
    long long temp;
    temp=a%b;
    a=b;
    b=temp;
    if(b==0){
        return a;
    }
    else return GCD(a,b);
}
long long LCM(long long a,long long b){
    return ((a/GCD(a,b))*b);
}

int main(){
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long cn,dn,in;
    cn=((b/c)-((a-1)/c));
    dn=((b/d)-((a-1)/d));
    //if(a%c==0)cn++;
    //if(b%c==0)cn++;
    //if(a%d==0)dn++;
    //if(b%d==0)dn++;
    long long lcm;
    lcm=LCM(c,d);
    in=((b/lcm)-((a-1)/lcm));
    cout<<(b-a+1)-(cn+dn-in);
    //cout<<" "<<cn<<" "<<dn<<" "<<in;
    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;
using ll = long long;

int main(){
  int n;
  cin >> n;
  
  vector<tuple<string, ll, ll>> data(n);
  rep(i, n){
    string s;
    ll p;
    cin >> s >> p;
    data.at(i) = make_tuple(s, -p, i + 1);
  }
  
  sort(data.begin(), data.end());
  
  rep(i, n){
    cout << get<2>(data.at(i)) << endl;
  }
  
}

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

int main(){
	int n;
	cin >> n;
	vector<double> a(n);

	rep(i, n){
		int d;
		cin >> d;
		a.at(i) = (double)1/d;
	}
	
	double sum = 0;
	rep(i, n) sum += a.at(i);

	cout << 1/sum << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
r,s,p=map(int,input().split())
scores={'r':p,'s':r,'p':s}
t=input()

ts=[t[i:len(t):k] for i in range(k)]
def score_str(l):
  res=0
  stt=0
  for i,c1,c2 in zip(range(len(l)),l,l[1:]+' '):
    if c1!=c2:
      res+=scores[c1]*((i-stt+2)//2)
      stt=i+1
  return res
print(sum(score_str(l) for l in ts))

Measured memory_bytes: 8820
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
ll digitsum(ll n){
  if(n == 0){
    return 0;
  }else
    return n%10 + digitsum(n/10);
}
int main()
{
  ll K,i,b=1,j;
  double min=1.0E15;
  vector<ll> snukekoho,snuke;
  cin >> K;
  i=100;
  for(i=1;i<=9;i++)
    snukekoho.push_back(i);
  for(i=10;i<=10E12;i*=10)
    for(j=1;j<=1000;j++){
      snukekoho.push_back(j*i - 1);
    }
  sort(snukekoho.begin(),snukekoho.end());
  snukekoho.erase(unique(snukekoho.begin(), snukekoho.end()), snukekoho.end());
  for(i=snukekoho.size()-1;i>=0;i--){
    if(min >= (double)snukekoho[i]/digitsum(snukekoho[i])){
      min = (double)snukekoho[i]/digitsum(snukekoho[i]);
      
      snuke.push_back(snukekoho[i]);
    }
  }
  sort(snuke.begin(),snuke.end());
  REP(i,K){
    cout << snuke[i] << endl;
  }
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    vector<int> a = igets(3);
    DSORT(a);
    
    cout << a[0]+a[1]+a[2]-a[1]*2 << endl;
    
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

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

int main(void) {
    string s;
    cin >> s;
    int l = s.size(),ac=0,ma=-1;
    for (int i = 0; i < l; i++) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' | s[i] == 'T') {
            ac++;
        }
        else {
            ma = max(ma, ac);
            ac = 0;
        }
    }
    ma = max(ma, ac);
    cout << ma << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int X;
    cin >> X;

    int n = X / 100;
    bool ans = false;
    int temp = X % 100;
    for (int b = 0; !ans && b <= MIN(temp, n); ++b)
    {
        for (int c = 0; !ans && c <= MIN(temp / 2, n - b); ++c)
        {
            for (int d = 0; !ans && d <= MIN(temp / 3, n - b - c); ++d)
            {
                for (int e = 0; !ans && e <= MIN(temp / 4, n - b - c - d); ++e)
                {
                    for (int f = 0; !ans && f <= MIN(temp / 5, n - b - c - d - e); ++f)
                    {
                        if (b + 2 * c + 3 * d + 4 * e + 5 * f == temp)
                        {
                            ans = true;
                        }
                    }
                }
            }
        }
    }


    cout << (ans ? 1 : 0) << "\n";
    return 0;
}



Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)

lamps = m.times.map do
  k, *s = *gets.split.map(&:to_i)
  s
end

lamps = lamps.zip(gets.split.map(&:to_i))

ans = (0..(2**n - 1)).map do |pattern|
  pattern = pattern.to_s(2).rjust(n, '0').chars.map(&:to_i)
  lamps.select do |(s, p)|
    s.map do |sw|
      pattern[sw-1]
    end.inject(:+) % 2 != p
  end.empty?
end.count(true)

puts ans


Measured memory_bytes: 1916
#include<stdio.h>
#define N 2001

int keisan1(int ,int ,int *,int );
int main()
{
  int A[N],i,n,q,a;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&a);
      if( keisan1(0,a,A,n))printf("yes\n");
      else printf("no\n");
    }
  return 0;
}

int keisan1(int i,int a,int A[],int n)
{
  if(a==0)return 1;
  if(i>=n)return 0;
  int res;
  res = keisan1(i+1,a - A[i],A,n) || keisan1(i+1,a,A,n);
  return res;
}

  



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

long long a, b;
int main()
{
	cin >> a >> b;
	if (a * b <= 0) cout << "Zero";
	else if (a > 0 || b - a & 1) cout << "Positive";
	else cout << "Negative";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#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 h, w;
  while (1) {
    cin >> h >> w;
    if (h == 0 && w == 0)
      break;
    rep(i, h) {
      rep(j, w) {
        if (i == 0 || j == 0 || i == h - 1 || j == w - 1)
          cout << "#";
        else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3092
D=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(D):
  s.append(list(map(int,input().split())))
sum_c=sum(c)
for i in range(D):
  max_s=0
  for j in range(26):
    hantei=s[i][j]-sum_c+c[j]
    if hantei>max_s:
      max_s=hantei
      index=j
  print(index+1)

Measured memory_bytes: 9236
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long int ll;

int main(){
    long n;
    std::cin >> n;
    vector<pair<ll,ll>> d(n);
    for( auto& v : d ){
        std::cin >> v.first >> v.second;
    }
    sort( d.begin(), d.end(), [](const pair<ll,ll>& lhs, const pair<ll,ll>& rhs){
        return lhs.second < rhs.second;
    });
    ll time = 0;
    for( auto v : d ){
        time += v.first;
        if ( v.second < time ){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a,b;
  int c=0;
  cin>>a>>b;
  rep(i,10000000000000000000000){
    a*=2;
      c++;
    if(a>b)
      break;
    }
  cout<<c;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
import java.awt.geom.*;
 class Main{
    public static void main(String[] args) {
        MyScanner sc=new MyScanner();
        int c[][]=new int[4][4];
        for(int i=1;i<=3;i++)
            for(int j=1;j<=3;j++){
                c[i][j]=sc.ni();
            }
        boolean f=true;
        HashSet<Integer> hs=new HashSet<>();
        hs.add(c[1][1]-c[2][1]);hs.add(c[1][2]-c[2][2]);hs.add(c[1][3]-c[2][3]);
        if(hs.size()>1) f=false;
        hs.clear();

        hs.add(c[2][1]-c[3][1]);hs.add(c[2][2]-c[3][2]);hs.add(c[2][3]-c[3][3]);
        if(hs.size()>1) f=false;
        hs.clear();
        
        hs.add(c[1][1]-c[3][1]);hs.add(c[1][2]-c[3][2]);hs.add(c[1][3]-c[3][3]);
        if(hs.size()>1) f=false;
        hs.clear();

        hs.add(c[1][1]-c[1][2]);hs.add(c[2][1]-c[2][2]);hs.add(c[3][1]-c[3][2]);
        if(hs.size()>1) f=false;
        hs.clear();

        hs.add(c[1][2]-c[1][3]);hs.add(c[2][2]-c[2][3]);hs.add(c[3][2]-c[3][3]);
        if(hs.size()>1) f=false;
        hs.clear();

        hs.add(c[1][1]-c[1][3]);hs.add(c[2][1]-c[2][3]);hs.add(c[3][1]-c[3][3]);
        if(hs.size()>1) f=false;
        hs.clear();

        if(!f) System.out.println("No");
        else System.out.println("Yes");
    }


    private static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }

      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }

      int ni() {
          return Integer.parseInt(next());
      }
      float nf() {
        return Float.parseFloat(next());
    }
      long nl() {
          return Long.parseLong(next());
      }

      double nd() {
          return Double.parseDouble(next());
      }

      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }
   }
}

Measured memory_bytes: 23252
#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>;
 
string k;

int main() {
    cin >> k;
    if (k == "ARC") {
        cout << "ABC";
    }
    else {
        cout << "ARC";
    }
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
inline int Abs(int a){return a<0?-a:a;}
int n,x,y;
inline int cal(int a,int b)
{
	int ans=Abs(b-a);
	ans=min(ans,Abs(a-x)+Abs(b-y)+1);
	ans=min(ans,Abs(b-x)+Abs(a-y)+1);
	return ans;
}
int ans[2010];
int main()
{
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) ans[cal(i,j)]++;
	for(int i=1;i<=n-1;i++) cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N, A[200010]; 
signed main() {
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];

    int ans = 0, ub = 0, sum = 0;
    for(int lb=0; lb<N; lb++) {
        while(ub < N and (sum & A[ub]) == 0) {
            sum += A[ub];
            ub++;
        }
        // fprintf(stderr, "lb = %lld, ub = %lld\n", lb, ub);

        int w = ub - lb;
        ans += w;
        sum -= A[lb];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
N = gets.chomp.to_i
L_ARR = gets.chomp.split(" ").map{|s| s.to_i }.sort

count = 0
(N-2).times do |i|
  a = L_ARR[i]
  n = 2+i
  (N-i-2).times do |j|
    b = L_ARR[j+i+1]
    max_length = a + b
    if n == N-1 && L_ARR[n] < max_length
	  count += n-(i+j+1) 
      next
    end
    (N-n).times do |k|
      c = L_ARR[n+k]
      if n+k == N-1 && c < max_length
        count += n+k-(j+i+1)
        n = n+k
        break
      elsif c >= max_length
        count += n+k-(j+i+1)-1
        n = n+k
        break
      end
    end
  end
end

puts count

Measured memory_bytes: 1916
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int N,ans=0;
    string S;
    cin>>N>>S;
    REP(i,N-1){
        string a,b,aa,bb;
        a=S.substr(0,i+1);
        b=S.substr(i+1,N-1);
        REP(y,a.size())if(aa.find(a[y])==string::npos)aa+=a[y];
        int sum=0;
        REP(y,b.size()){
            if(aa.find(b[y])!=string::npos){
                if(bb.find(b[y])==string::npos){
                    bb+=b[y];
                    sum++;
                }
            }
        }
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
now, nx, ny = [0, 0, 0]

f = True
for i in range(n):
    t, x, y = map(int, input().split())
    mdist = abs(nx-x) + abs(ny-y)
    if t - now < mdist:
        f = False
        break
    elif mdist%2 != (t-now)%2:
        f = False
        break
    else:
        now = t
        nx, ny = x, y
if f:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9068
#include<iostream>
using namespace std;
int main(void)
{
	int n;
	int a[100];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		int k = a[i];
		int flag = 0;
		for (int j = 0; j < i ; j++)
		{
			if (a[i] < a[j])
			{
				for (int m = i; m > j; m--) {
					a[m] = a[m - 1];
				}
				a[j] = k;
				break;
			}
		}
		for (int t = 0; t < n; t++) {
			if (t > 0) cout << " ";
			cout << a[t];
		}
		cout << endl;
	}
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)

ll a[400010];
ll N;

int main(void)
{
    cin >> N;
    ll N3 = N * 3;
    REP(i, N3) cin >> a[i];
    sort(a, a+N3, greater<long long>());
    ll sum = 0;
    REP(i, N) sum += a[i*2+1];
    cout << sum << endl;

}



Measured memory_bytes: 2560
using System;
using System.Linq;

namespace AltCoder
{
    public sealed class D_Knapsack1
    {
        public static void Main()
        {
            long[] NW = Console.ReadLine().Split(new char[] { ' ' }).Select(x => Convert.ToInt64(x)).ToArray();
            long N = NW[0];
            long maxWeight = NW[1];

            long[] weights = new long[N];
            long[] values = new long[N];

            for (long i = 0; i < N; i++)
            {
                long[] input = Console.ReadLine().Split(new char[] { ' ' }).Select(x => Convert.ToInt64(x)).ToArray();
                weights[i] = input[0];
                values[i] = input[1];
            }

            long[,] d = new long[N + 1, maxWeight + 1];

            for (long i = 0; i < N; i++)
            {
                for (long w = 0; w <= maxWeight; w++)
                {
                    if (weights[i] <= w)
                    {
                        d[i + 1, w] = Math.Max(d[i + 1, w], d[i, w - weights[i]] + values[i]);
                    }

                    d[i + 1, w] = Math.Max(d[i + 1, w], d[i, w]);
                }
            }

            Console.WriteLine(d[N, maxWeight]);
        }
    }
}


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

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

    rep(i,N)
        cin >> A.at(i);
    sort(A.begin(), A.end());

    cout << A.at(N-1)-A.at(0) << endl;
}

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

struct edge {
    edge(int n, int m){
        u = min(n, m);
        v = max(n, m);
    }
    int u, v;
};

vector<vector<int>> dist;
vector<vector<int>> nParent;
vector<vector<vector<edge>>> child;

void dfs(edge now){
    for(edge e : child[now.u][now.v]){
        if(nParent[e.u][e.v] == 0 || dist[e.u][e.v] == 1e9){
            dist[e.u][e.v] = 1e9;
            continue;
        }
        nParent[e.u][e.v]--;
        dist[e.u][e.v] = max(dist[e.u][e.v], dist[now.u][now.v] + 1);
        if(nParent[e.u][e.v] == 0){
            dfs(e);
        }
    }
}

int main(){
    int N;  cin >> N;
    vector<vector<int>> A(N, vector<int>(N-1, 0));
    for(int i=0; i<N; i++) for(int j=0; j<N-1; j++){
        cin >> A[i][j];  A[i][j]--;
    }

    child.resize(N, vector<vector<edge>>(N));
    nParent.resize(N, vector<int>(N, 0));
    dist.resize(N, vector<int>(N, 0));
    for(int i=0; i<N; i++) for(int j=0; j<N-2; j++){
        edge now = edge(i, A[i][j]);
        edge next = edge(i, A[i][j+1]);
        child[now.u][now.v].push_back(next);
        nParent[next.u][next.v]++;
    }

    vector<edge> root;
    for(int i=0; i<N; i++) for(int j=i+1; j<N; j++){
        edge e = edge(i, j);
        if(nParent[e.u][e.v] == 0){
            root.push_back(e);
        }
    }
    if(root.size() == 0){
        cout << -1 << endl;
        return 0;
    }

    for(edge r : root){
        dfs(r);
    }
    int ans = 0;
    for(int i=0; i<N; i++) for(int j=i+1; j<N; j++){
        ans = max(ans, dist[i][j]);
        if(dist[i][j] == 0 && nParent[i][j] != 0){
            ans = 1e9;
        }
    }
    if(ans >= 1e9){
        cout << -1 << endl;
    }else{
        cout << ans + 1 << endl;
    }
}


Measured memory_bytes: 51328
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

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

	if (a < b&&b<c){
		printf("Yes\n");
		} else
	{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2076
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

vector<int> v(4);
string res;

void cal(int ind,int now,int next,int ope,string st){
    string ans = st;
    if(ope > 0)ans += '+';
    else ans += '-';
    ans += (next + '0');

    int sum = now;
    if(ope > 0)sum += next;
    else sum -= next;

    if(ind == 3){
        ans += '=';
        ans += (sum + '0');
        if(sum == 7)res = ans;
        return;
    }

    cal(ind+1,sum,v[ind+1],1,ans);
    cal(ind+1,sum,v[ind+1],-1,ans);
}

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

    rep(i,4){
        int t = s[i] - '0';
        v[i] = t;
    }

    string st;
    st += (v[0] + '0');
    cal(1,v[0],v[1],1,st);
    cal(1,v[0],v[1],-1,st);

    for(auto t : res)cout << t;
    cout << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int main(){
	int N;
	string S;
	cin >> N >> S;
	int num[N];
	num[0] = 0;
	if(S[0] == '#')num[0] = 1;
	for(int i=1;i<N;i++){
		if(S[i] == '#') num[i] = num[i-1] + 1;
		else num[i] = num[i-1];
	}
	int ans = N - num[N-1];
	for(int i=0;i<N-1;i++){
		ans = min(num[i] + N - i - 1 - num[N-1] + num[i],ans);
	}
	ans = min(ans, num[N-1]);
	cout << ans << endl;
}

Measured memory_bytes: 1412
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  string s;

  cin >> n >> s;

  char last = s[0];
  int ans = 1;

  for(int i = 1; i < n; ++i){
    if(s[i] != last){
      ans++;
      last = s[i];
    }
  }

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



Measured memory_bytes: 512
#include<iostream>
#include<vector>

using namespace std;

int main() {
  int num;
  cin>>num;
  
  vector<int> perms(num);
  for(int i = 0; i < num; i++) {
    cin>>perms[i];
  }
  
  int count = 0;
  for(int i = 1; i < num-1; i++) {
    if(((perms[i-1] > perms[i]) && (perms[i] > perms[i+1])) || ((perms[i-1] < perms[i]) && (perms[i] < perms[i+1]))) {
      count++;
    }
  }
  
  cout<<count<<endl;
  
  return 0;
}

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

using int64 = long long;
using i64 = int64;

const int inf = 1<<30;
const int64 inf64 = 1ll<<60;

#define rep(i,N) for(int i=0; i<(int)N; ++i)

int64 dp[1001][1001];
int s[1001][1001];
i64 sumh[1001][1001], sumw[1001][1001];

signed main() {
	int W, H; cin >> W >> H;
	rep(i, H) rep(j, W) cin >> s[i][j];
	
	rep(i, H) {
		sumh[i][0] = s[i][0];
		for(int j=1; j<W; ++j) sumh[i][j] += sumh[i][j-1] + s[i][j];
	}
	rep(j, W) {
		sumw[0][j] = s[0][j];
		for(int i=1; i<H; ++i) sumw[i][j] += sumw[i-1][j] + s[i][j];
	}
	
	dp[H-1][W-1] = 0;
	for(int i=H; i>=0; --i) {
		for(int j=W; j>=0; --j) {
			if(i == H && j == W) continue;
			
			i64 n1 = inf64;
			if(i + 1 <= H) {
				if(j != 0) n1 = dp[i+1][j] + (sumh[i][W-1] - sumh[i][j-1]);
				else n1 = dp[i+1][j] + sumh[i][W-1];
			}
			
			i64 n2 = inf64;
			if(j + 1 <= W) {
				if(i != 0) n2 = dp[i][j+1] - (sumw[H-1][j] - sumw[i-1][j]);
				else n2 = dp[i][j+1] - sumw[H-1][j];
			}
			
			if((i + j) % 2 == 0) {
				if(n1 == inf64) dp[i][j] = n2;
				else if(n2 == inf64) dp[i][j] = n1;
				else dp[i][j] = max({ n1, n2});
			}
			else {
				dp[i][j] = min({n1, n2});
			}
		}
	}
	
	/*
	rep(i, H + 1) {
		rep(j, W + 1) cout << dp[i][j] << " ";
		cout << endl;
	}*/
	
	
	cout << abs(dp[0][0]) << endl;
}
	
	


Measured memory_bytes: 30472
#include <iostream>
#include <vector>

int gcd(int a, int b)
{
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main()
{
    int N;
    std::cin >> N;

    std::vector<int> A(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
    }

    std::vector<int> L(N), R(N);
    L[0] = A[0]; R[N - 1] = A[N - 1];
    for (int i = 1; i < N; i++) {
        L[i] = gcd(L[i - 1], A[i]);
    }

    for (int i = N - 2; i >= 0; i--) {
        R[i] = gcd(R[i + 1], A[i]);
    }

    int max = std::max(R[1], L[N - 2]);
    for (int i = 1; i < N - 1; i++) {
        max = std::max(max, gcd(L[i - 1], R[i + 1]));
    }

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

Measured memory_bytes: 1408
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

std::vector<int> solve(int n, const std::vector<std::string>& strings)
{
  std::vector<int> counts(4, 0);
  for (auto& s : strings) {
    if (s == "AC") {
      ++counts.at(0);
    } else if (s == "WA") {
      ++counts.at(1);
    } else if (s == "TLE") {
      ++counts.at(2);
    } else if (s == "RE") {
      ++counts.at(3);
    }
  }
  return counts;
}

int main()
{
  int n;
  std::cin >> n;
  std::vector<std::string> strings(n);
  for (auto& s : strings) {
    std::cin >> s;
  }

  const auto counts = solve(n, strings);
  std::cout << std::setprecision(20);
  std::cout << "AC x " << counts.at(0) << std::endl;
  std::cout << "WA x " << counts.at(1) << std::endl;
  std::cout << "TLE x " << counts.at(2) << std::endl;
  std::cout << "RE x " << counts.at(3) << std::endl;
}


Measured memory_bytes: 6352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  
  int sum = 0;
  int t = N;
    while (t > 0) {
      sum += t % 10;
      t /= 10;
    }
  
 
  if(N % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> m(N);
  for (int i = 0; i < N; i++) {
    cin >> m.at(i);
  }
  
  sort(m.begin(), m.end());
  
  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans = ans + m.at(i);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3628
N,M,X = map(int,input().split())
data = []
for _ in range(N):
    data.append(list(map(int,input().split())))
cost = float("inf")
for i in range(2**N):
    temp = [0] * (M+1)
    for j in range(N):
        if ((i>>j)&1):
            for x in range(M+1):
                temp[x] += data[j][x]
    count = 0
    for f in temp[1:]:
        if f < X:
            break
        count += 1
    if count == M:
        cost = min([cost,temp[0]])
if cost == float("inf"):
    print(-1)
else:
    print(cost)

Measured memory_bytes: 9144
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"

using namespace std;
const long long int MOD = 1000000007;

int N;
int box;
int num[111111] = {};
int s, e;
int ans=0;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> box;
		num[box]++;
	}
	s = -1;
	for (int i = 1; i <= 100001; i++) {
		if (s == -1) {
			if (num[i] > 1) {
				s = i;
			}
		}
		if (num[i] > 1)e = i;
		ans += num[i];
	}
	//cout << ans << endl;
	if (s == -1) {
		cout << N << endl;
		return 0;
	}
	box = 0;
	while (1) {
		num[s]--;
		num[e]--;
		box += 2;
		for (int i = s; i <= e; i++) {
			s = -1;
			if (num[i] > 1) {
				s = i;
				break;
			}
		}
		if (s == -1) {
			break;
		}
		for (int i = e; i >= s; i--) {
			e = -1;
			if (num[i] > 1) {
				e = i;
				break;
			}
		}
		if (e == -1)break;
	}

	cout << N - box << endl;
	return 0;
}



Measured memory_bytes: 640
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

trait Monoid {
   fn unit() -> Self;
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
enum MinInt {
   Val(i64),
   Maximal,
}
impl MinInt {
   fn unwrap(self) -> i64 {
      if let Self::Val(x) = self {
         x
      } else {
         panic!();
      }
   }
}
impl std::ops::Add for MinInt {
   type Output = Self;
   fn add(self, other: Self) -> Self {
      match (self, other) {
         (Val(x), Val(y)) => Val(x + y),
         _ => self::MinInt::Maximal,
      }
   }
}
impl std::ops::Mul for MinInt {
   type Output = Self;
   fn mul(self, other: Self) -> Self {
      if self < other {
         self
      } else {
         other
      }
   }
}
impl Monoid for MinInt {
   fn unit() -> Self { MinInt::Maximal }
}
use MinInt::*;

fn set_cost(cost: &mut Vec<MinInt>, n: usize, xyp: &Vec<(i64, i64, i64)>) {
   let num = 1 << n;
   for s in 0..num {
      let mut idx = vec![];
      let mut tot = 0;
      for i in 0..n {
         if (s >> i) & 1 == 0 {
            continue;
         }
         idx.push(i);
         tot += xyp[i].2;
      }
      let mut cx: i64 = 0;
      let mut cy: i64 = 0;
      if idx.len() > 1 {
         idx.sort_by_key(|&i| xyp[i].0);
         let mut m = 0;
         let mut i = 0;
         while m < tot / 2 {
            m += xyp[idx[i]].2;
            i += 1;
         }
         let mx = xyp[idx[i - 1]].0;
         for (x, _, p) in idx.iter().map(|&i| xyp[i]) {
            cx += p * (x - mx).abs();
         }
         idx.sort_by_key(|&i| xyp[i].1);
         let mut m = 0;
         let mut i = 0;
         while m < tot / 2 {
            m += xyp[idx[i]].2;
            i += 1;
         }
         let my = xyp[idx[i - 1]].1;
         for (_, y, p) in idx.iter().map(|&i| xyp[i]) {
            cy += p * (y - my).abs();
         }
      }
      cost[s] = Val(min(cx, cy));
   }
}

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

   let num = 1 << n;
   let mut cost = vec![Maximal; num];
   set_cost(&mut cost, n, &xyp);

   let mut dp = vec![vec![Maximal; n + 1]; num];
   for s in 0..num {
      let mut c = 0i64;
      for i in 0..n {
         if (s >> i) & 1 == 1 {
            let (x, y, p) = xyp[i];
            c += p * min(x.abs(), y.abs());
         }
      }
      dp[s][0] = Val(c);
   }

   for i in 0..n {
      for s in 0..num {
         let mut t = vec![0];
         for i in 0..n {
            if (s >> i) & 1 == 1 {
               for j in 0..t.len() {
                  t.push(t[j] | 1 << i);
               }
            }
         }
         for &t in t.iter() {
            dp[s][i + 1] = dp[s][i + 1] * (dp[s ^ t][i] + cost[t]);
         }
      }
   }
   for i in 0..=n {
      println!("{}", dp[num - 1][i].unwrap());
   }
}


Measured memory_bytes: 12308
import sys

line1 = sys.stdin.readline()
line2 = sys.stdin.readline()

line1 = line1.replace('\n', '')
line2 = line2.replace('\n', '')

line1 = sorted(line1)
line2 = sorted(line2, reverse=True)

# print(line1)
# print(line2)

flag = 0
if len(line1) < len(line2):
    flag = 1

if flag == 1:
    for x, y in zip(line1, line2):
        if x > y:
            flag = 0
            break
        elif x < y:
            flag = 1
            break

else:
    for x, y in zip(line1, line2):
        if x < y:
            print("Yes")
            flag = -1
            break
# print(flag)
if flag == 1:
    print("Yes")
elif flag != -1:
    print("No")


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

int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    if(a[i]%2==0 && (a[i]%3!=0 && a[i]%5!=0))
    return cout<<"DENIED",0;
  }
  return cout<<"APPROVED", 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  ll a, b; cin >> a >> b;
  b++;

  ll aa = (a/2) % 2;
  if (a % 2) aa ^= a-1;
  ll bb = (b/2) % 2;
  if (b % 2) bb ^= b-1;

  ll ans = aa ^ bb;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
a = input()
b = 0
c = ["A","C","G","T"]
d = []
for i in range(len(a)):
    if a[i] in c:
      b += 1  
      d.append(b)
    else:
      b = 0
      d.append(b)
#print(d)
print(max(d))

Measured memory_bytes: 2940
from sys import stdin
input = stdin.readline


def main():
  A, B = input().split()
  A = int(A)
  # B = int(100*float(B))
  B = int(B[0]+B[2:])

  # print((A*B)//100)
  if A*B < 100:
    print(0)
  else:
    print(str(A*B)[:-2])


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 61340
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
        if(a<b) cout<<"a < b"<<endl;
else if(a>b) cout<<"a > b"<<endl;
else cout<<"a == b"<<endl;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f,N=1e6;
int n,m,a[N],nxt[N],pre[N];
char c[N];
void pt(int x)
{
	if(x==0)return;
	pt(pre[x]);printf("%d ",x-pre[x]);
}
int main()
{
	cin>>n>>m;
	scanf("%s",c);
	for(int i=n;i;i--)
	{
		if(c[i]=='0')nxt[i]=i;
		else nxt[i]=nxt[i+1];
	}
	for(int i=1;i<=n;i++)
	{
		int j=max(0,i-m);
		j=nxt[j];
		if(j>=i)return puts("-1"),0;
		pre[i]=j;
	}
	pt(n);
	return 0;
}


Measured memory_bytes: 6144
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <stdio.h>
#include <vector>
#include <functional>
#include <unordered_set>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;


int main()
{
	int n, k;
	cin >> n >> k;
	int cnt = 1;
	for (int i = 0; i < k - 1; ++i) {
		cnt += 2;
	}
	if (cnt <= n) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}
	return 0;
}

Measured memory_bytes: 256
import io.{StdIn => in}

object Main extends App {
  val Array(a, b) = in.readLine.split(" ").map(_.toLong)
  val ap = if(a == 1) 14 else a
  val bp = if(b == 1) 14 else b
  val ans = if(ap == bp) "Draw" else if(ap > bp) "Alice" else "Bob"
  println(ans)
}

Measured memory_bytes: 25540
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 2000000000;



int main(){
  int n, T;
  cin >> n >> T;
  vector<int> t(n);
  REP(i,n) cin >> t[i];

  t.push_back(INF);

  int sum = 0;
  REP(i,n){
    int time = min(T, t[i+1]-t[i]);
    sum += time;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 4684
#include<stdio.h>
int main()
{
	int t=0;
	int y=0;
	int glaf[110][110]={0};

	scanf("%d %d",&t,&y);
	for(int i=0;i<t;i++)
	{
		for(int j=0;j<y;j++)
		{
			scanf("%d",&glaf[i][j]);
		}
	}

	for(int ii=0;ii<t;ii++)
	{
		for(int jj=0;jj<y;jj++)
		{
			glaf[ii][y]+=glaf[ii][jj];
		}
	}
	
	for(int iii=0;iii<y;iii++)
	{
		for(int jjj=0;jjj<t;jjj++)
		{
			glaf[t][iii]+=glaf[jjj][iii];
		}
	}

	for(int a=0;a<y;a++)
	{
		glaf[t][y]+=glaf[t][a];
	}

	for(int iiii=0;iiii<t+1;iiii++)
	{
		for(int jjjj=0;jjjj<y+1;jjjj++)
		{
			printf("%d",glaf[iiii][jjjj]);
			if(jjjj!=y) printf(" ");
		}
		printf("\n");
	}
	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const int MAX_N = 30;
const int MAX_X = 30;
const int MAX_Y = 30;
int n, m;
int x[MAX_N], y[MAX_N];
map<char, int> hm;
char c;
int d;
bool flag[MAX_X+1][MAX_Y+1];

int main()
{
  hm['W'] = 0;
  hm['S'] = 1;
  hm['E'] = 2;
  hm['N'] = 3;

  while(cin >> n, n){
    int cnt = 0;
    int hx = 10;
    int hy = 10;
    erep(i, 0, MAX_X) erep(j, 0, MAX_Y) flag[i][j] = false;

    rep(i, n){
      cin >> x[i] >> y[i];
      flag[x[i]][y[i]] = true;
      cnt += 1;
    }

    cin >> m;
    rep(i, m){
      cin >> c >> d;
      rep(j, d){
        hx += dx[hm[c]];
        hy += dy[hm[c]];
        if(flag[hx][hy]){
          cnt -= 1;
          flag[hx][hy] = false;
        }
      }
    }

    puts(cnt == 0 ? "Yes" : "No");
  }

  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
signed main(){
  int a,ans=0;
  int b[]={1,5,10,50,100,500};
  for(int i=0;i<6;i++){
    cin>>a;
    ans+=(b[i]*a);
  }
  if(ans>=1000) cout<<"1\n";
  else cout<<"0\n";
}



Measured memory_bytes: 3064