akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>


int main(void){
	int K,A,B;
  
  scanf("%d", &K);
  scanf("%d %d", &A, &B);
  
  for(int i = A; i<=B; i++){
    if(i % K == 0){
      printf("OK\n");
      return 0;
    }
  }
  printf("NG\n");
    

  return 0;
}



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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

using namespace std;
template<class T>void reg(vector<T> &ary,const T &elem){ary.emplace_back(elem);}

using R=long double; // __float128
const R EPS = 1E-14; // [-1000:1000]->EPS=1e-8 [-10000:10000]->EPS=1e-7
inline int sgn(const R& r){ return (r > EPS) - (r < -EPS);}
inline int sgn(const R& a, const R &b){ return sgn(a-b); }

using P=complex<R>;
using VP=vector<P>;
using L=struct{P s,t;};
using VL=vector<L>;

constexpr P O = P(0,0);
istream& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}


inline R dot(P o,P a,P b){a-=o,b-=o; return real(conj(a)*b);}
inline R det(P o,P a,P b){a-=o,b-=o; return imag(conj(a)*b);}

P cross(L a,L b){
	R s1=det(a.s,b.s,b.t);
	R s2=s1+det(a.t,b.t,b.s);
	return a.s+s1/s2*(a.t-a.s);
}

VP convex_cut(const VP& pol,const L& l) {
	VP res;
	int n=pol.size();
	rep(i,n){
		P a = pol[i],b=pol[(i+1)%n];
		if(det(l.s,l.t,a)>=0) reg(res,a);
		if(det(l.s,l.t,a)*det(l.s,l.t,b)<0) reg(res,cross({a,b},l));
	}
	return res;
}

R area(const VP& pol){
	int n=pol.size();
	R sum=0;
	rep(i,n) sum+=det(O,pol[i],pol[(i+1)%n]);
	return abs(sum/2.0);
}

bool check(VP pol,R len){
	int n=pol.size();
	VL lines(n);

	rep(i,n){
		P e=(pol[(i+1)%n]-pol[i])/abs(pol[(i+1)%n]-pol[i])*P(0,1);
		lines[i]=L({pol[i]+e*len,pol[(i+1)%n]+e*len});
	}

	VP cur=pol;
	rep(i,n) cur=convex_cut(cur,lines[i]);
	return sgn(area(cur));
}

int main(void){
	int n;
	while(cin >> n,n){
		VP pol(n);
		rep(i,n) cin >> pol[i];

		R lb=0.0,ub=20000.0;

		rep(loop,200){
			const R mid=(lb+ub)/2.0;
			if(check(pol,mid))
				lb=mid;
			else
				ub=mid;
		}

		cout.precision(20);
		cout << fixed << lb << endl;
	}
	return 0;
}

Measured memory_bytes: 3296
import bisect
n,k = map(int,input().split())
xl = list(map(int,input().split()))
x1 = xl[:bisect.bisect_right(xl,0)][::-1]
x2 = xl[bisect.bisect_right(xl,0):]
m = 10**10
if len(x1) >= k:
  m = min(m,-x1[k-1])
if len(x2) >= k:
  m = min(m,x2[k-1])
for i in range(k-1):
  try:
    m = min(m,x2[i]-2*x1[k-i-2],2*x2[i]-x1[k-i-2])
  except:
    continue
print(m)

Measured memory_bytes: 14480
#include<bits/stdc++.h>
using namespace std;
const long long INF=1000000000;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    int a[n];
    pair<int, int> max=make_pair(0,-100), second=make_pair(0,-100);
    
    for (int i = 0; i < n;i++){
        cin >>a[i];
        if(a[i]>max.second){
            second = make_pair(max.first, max.second);
            max = make_pair(i - 1, a[i]);
        }else if(a[i]>second.second){
            second = make_pair(i - 1, a[i]);
        }
    }
    for (int i = 0; i < n;i++){
        if((i-1)!=max.first){
            cout << max.second << endl;
        }else{
            cout << second.second << endl;
        }
    }
        return 0;
}

Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        double aa = a * 100 / 8.0;
        double bb = b * 10;
        double la = (a + 1) * 100 / 8.0;
        double lb = (b + 1) * 10;
        if (aa == bb) {
            System.out.println((int)aa);
        } else if (aa > bb) {
            if (bb <= aa && aa < lb) {
                System.out.println((int)Math.ceil(aa));
            } else {
                System.out.println(-1);
            }
        } else {
            if (aa <= bb && bb < la) {
                System.out.println((int)Math.ceil(bb));
            } else {
                System.out.println(-1);
            }
        }
    }
}

Measured memory_bytes: 25044
#include<iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
 
using namespace std;

#define ll  long long
#define forn(i,n)   for(ll i=0;i<(ll)n;i++)

int count(string s,string t)
{
    int days=0;
    forn(i,3)
    {
        if(s[i]==t[i])
            days++;
    }
    return days;
}
int main()
{
    string s,t;
    cin>>s>>t;
    cout<<count(s,t)<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int a, b, c;
int main(void) {
    cin >> a >> b >> c;
    cout << a + b + c - max({ a,b,c }) << endl;
    return 0;
}

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

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main(void){
    // Your code here!
    int n;
    cin >> n;
    UnionFind<int> uf(n);
    for (int i = 0; i < n-1; i++) {
        int u,v,w;
        cin >> u >>v>>w;
    uf.merge(u-1,v-1,w%2)     ;   /* code */
    }
    for (int i = 0; i < n; i++) {
    cout << (uf.diff(0,i)+200000)%2  << endl;
}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long
using namespace std;
double EPS = 1e-9;

int main()
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    int x, y;
    scanf("%d %d", &x, &y);

    int min_price = 1e9;
    for(int i = 0;i <= max(2*x, 2*y);i += 2){
        int p = i * c;
        p += max(0, x - i/2) * a;
        p += max(0, y - i/2) * b;
        min_price = min(min_price, p);
    }
    printf("%d", min_price);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
 
using namespace std;
 
#define deb(x) cout << #x << " " << x << endl;
 
typedef long long ll;
#define For(i,n) for(int i=0;i<n;i++)
const ll mod = 1000000007;
 
 
ll binpow(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        x>>=1;
    }
    return res;
}
 
ll modInverse(ll a, ll m) 
{ 
    return(binpow(a, m-2)); 
} 
 
 
ll binomialCoeff(ll n, ll k)  
{  
    ll res = 1; 
    ll den=1; 
    ll inv;
    if ( k > n - k )  
        k = n - k;  
    for (ll i = 0; i < k; ++i)  
    {  
        res = (res*(n - i))%mod; 
        inv=modInverse(i+1,mod);
        res=(res*inv)%mod;
    }  
    return res;  
}  
 
int main(){
    ll t,i,n,j,a,b;
    ll powe,ans;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n>>a>>b;
    powe=binpow((ll)2,n);
    //deb(powe);
    ans=(binomialCoeff(n,a)+binomialCoeff(n,b))%mod;
    powe=powe-ans-1;
   if(powe<0)
        powe+=mod;
    cout<<powe;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N,M;
  cin >> N >> M;
  vector<int> vec(N,0);
  vector<P> A(M);
  REP(i,M){
    cin >> A[i].first >> A[i].second;
    A[i].first--;
    A[i].second--;
    vec.at(A[i].first)++;
    vec.at(A[i].second)--;
  }
  
  int sum = 0;
  vector<int> ans(N);
  REP(i,N){
    sum+=vec.at(i);
    ans.at(i)=sum;
  }

  int flag=0;
  REP(i,N){
    if(ans.at(i)%2==1){
      flag=1;
    }
  }

  if(flag==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 4832
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	int res = 0,sum = 0;
	int n,a,b,c;
	n = sc.nextInt();
	a = sc.nextInt();
	b = sc.nextInt();
	c = sc.nextInt();


	int[] aa = new int[n];
	for(int i=0; i<n; i++){
	    aa[i] = sc.nextInt();
	}

	Arrays.sort(aa);
	//System.out.println(Arrays.toString(aa));
	//Arrays.reverse(aa);
	for(int i=0; i<n/2; i++){
	    int tmp = aa[i];
	    aa[i] = aa[aa.length-1-i];
	    aa[aa.length-1-i] = tmp;
	}
	//System.out.println(Arrays.toString(aa));
	for(int i=0; i<n+1; i++){
	    res = Math.max(res,(c+sum)/(a+b*i));
	    if(i==n)break;
	    sum += aa[i];
	}
	System.out.println(res);
    }
}

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

#define NUM (2019)
#define SIZE (200000)

long long count[NUM];

main()
{
        int n;
        int c;
        char buf[SIZE + 1];
        int md[SIZE + 1];
        int tmp;
        int tens;
        int i, j;
        long long res;

//      memset(count, 0x00, sizeof(count));

        scanf("%s", buf);
        n = strlen(buf);

        tmp = 0;
        tens = 1;
        count[0] = 1;
        for(i = n - 1; i >= 0; --i) {
                tmp = ((buf[i] - '0') * tens + tmp + NUM) % NUM;
                count[tmp]++;
                tens = (tens * 10) % NUM;
        }
#if 0
        for(i = n - 1; i >= 0; --i) {
                tmp = (buf[i] * tens + tmp + NUM) % NUM;
                md[i] = tmp;
                tens = (tens * 10) % NUM;
        }
        md[n] = 0;

        for(i = 0; i <= n; ++i) {
                count[md[i]]++;
        }
#endif

        res = 0;
        for(i = 0; i < NUM; ++i) {
                res += count[i] * (count[i] - 1) / 2;
        }
        printf("%lld", res);
}


Measured memory_bytes: 1936
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

ll oddsolve(ll a) { return (a+1)/2 % 2; }
ll solve(ll a) {
    if (a % 2 == 1) return oddsolve(a);
    else return oddsolve(a+1) ^ (a+1);
}

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll A, B; 
    cin >> A >> B;
    cout << (solve(B) ^ solve(A-1)) << endl;
    

    return 0;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string t;
    cin >> t;

    for (char &c : t)
        if (c == '?')
            c = 'D';
    cout << t << "\n";

    return 0;
}


Measured memory_bytes: 3724
k = int(input())

Queue = [i for i in range(1, 10, 1)]

cnt = 0

while(cnt < k) : 
    cnt += 1
    x = Queue.pop(0)
    
    if cnt + len(Queue) >= k : 
        continue
    
    xx = x
    if len(str(xx)) >= 2 : 
        while(len(str(xx)) >= 2) : 
            xx = xx % 10

    ## 1つ目            
    if xx != 0 : 
        y = int("".join(map(str, [x, xx-1])))
        Queue.append(y)
        
    ## 2つ目            
    y = int("".join(map(str, [x, xx])))    
    Queue.append(y)

    ## 3つ目            
    if xx != 9 : 
        y = int("".join(map(str, [x, xx+1])))
        Queue.append(y)


print(x)

Measured memory_bytes: 5648
#include<stdio.h>
#include<string.h>
int main()
{
  int q,i,j;
  char S1[1001],S2[1001];
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%s",S1);
    scanf("%s",S2);
    printf("%d\n",LCS(S1,S2));
  }
  return 0;
}

int LCS(char *S1,char *S2)
{
  int c[1001][1001],i,j,x,y;
  x=strlen(S1)+1;
  y=strlen(S2)+1;
  for(i=1;i<x;i++)c[0][i]=0;
  for(i=0;i<y;i++)c[i][0]=0;
  
  for(i=1;i<x;i++){
    for(j=1;j<y;j++){
      if(S1[i-1]==S2[j-1])c[i][j]=c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1])c[i][j]=c[i-1][j];
      else c[i][j]=c[i][j-1];
    }
  }
  return c[x-1][y-1];
}

Measured memory_bytes: 4520
# coding: utf-8
# Your code here!

class Node:
    def __init__(self):
        self.parentId=-1
        self.sibling=-1
        self.children=[]
        self.degree=0
        self.depth=-1
        self.height=-1
        self.type=""
        
def calcDepth(x,depth):
    global node
    node[x].depth=depth
    for i in node[x].children:
        calcDepth(i,depth+1)

def calcHeight(x,height):
    global node
    node[x].height=max([height,node[x].height])
    if node[x].parentId != -1:
        calcHeight(node[x].parentId,height+1)

n=int(input())
a=[[int(i)for i in input().split()]for j in range(n)]
node=[Node()for i in range(n)]

for i in a:
    id=i[0]
    left=i[1]
    right=i[2]
    node[id].children=[left,right]
    if left != -1:node[left].sibling,node[left].parentId=right,id
    if right != -1:node[right].sibling,node[right].parentId =left,id

for i in node:
    while -1 in i.children:
        i.children.remove(-1)

for i in node:
    i.degree=len(i.children)

for i in range(n):
    if node[i].parentId==-1:
        calcDepth(i,0)
        break

for i in range(n):
    if node[i].degree==0:
        calcHeight(i,0)

for i in node:
    if i.parentId == -1:
        i.type="root"
    elif i.height==0:
        i.type="leaf"
    else:
        i.type="internal node"


for i in range(n):
    print("node "+str(i)+": parent = "+str(node[i].parentId)+", sibling = "+str(node[i].sibling)+", degree = "+str(node[i].degree)+", depth = "+str(node[i].depth)+", height = "+str(node[i].height)+", "+node[i].type)


Measured memory_bytes: 5624
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a%3==0 || b%3==0 ||(a+b)%3==0){
        cout <<"Possible";
    }else{
        cout << "Impossible";
    }
}

Measured memory_bytes: 256
import math

N,A,B = map(int, input().split())

H = [int(input()) for _ in range(N)]
H.sort(reverse=True)

# mid回の攻撃で全撃破できるか確認。
hi = H[0]
lo = 1


while hi - lo > 1:
    can_defeat_all_enemies = True
    mid = (hi+lo) // 2
    cnt_extra_attack = 0

    for i in range(N):
        if H[i] > mid * B:
            cnt_extra_attack += math.ceil((H[i] - mid * B) / (A - B))
        # 降順に並べてあるので、あるモンスターで追加攻撃が必要なければそれ以降も必要ない
        else:
            break
    
    # mid以下しか追加攻撃が必要ないので倒しきれる
    if cnt_extra_attack <= mid:
        hi = mid
    else:
        lo = mid

print(hi)


Measured memory_bytes: 7508
// compile & run:     g++ main.cpp -o main && ./main < input.txt > out.txt
// Problem Url:
//

#include <cstdio>
#include <iostream>

using namespace std;

string s,t;
//Saber en que posiciones t es subcadena de s
//La complejidad de su funcionamiento es O(|s| + |t|)

//Arreglo de la Función de Error. Debemos cuidar que el tamaño sea igual al peor tamaño de T , más 5.
//Si |T| <= 10⁵ , entonces :
int FE[100002];

//Calculamos la función de error
void FuncionError(){

	//Ya vimos que para la 0, su Fe es -1
	FE[0] = -1;

	//Vamos ir caracter por caracter
	for(int i = 0; i < t.size();){

		//Tomamos el caracter i para resolver la solución para la posición i+1.

		//Ya que queremos saber para i+1, el anterior es i, por lo tanto nos vamos
		//a su función de error.
		int pos = FE[i];

		//Iteramos mientras que la letra siguiente no sea igual a la siguiente de la función
		//de error. Adicionalmente, si pos se vuelve negativo, o sea -1, deja de moverse
		//hacia atras.
		while(pos >= 0 && t[pos] != t[i])
			pos = FE[pos]; //Usa la función de error para moverse hacia atras

		//Como s[pos] == s[i] , es como si los dos se movieran en el automata.
		//Y como el prefijo que termina en 'pos' es sufijo del prefijo que termina en i.
		//Y como s[pos] == s[i], entonces el prefijo que termina en 'pos+1' es sufijo
		//del que termina en i+1.
		FE[++i] = ++pos;

	}
}


//Imprime las posiciones en las que t se encuentra en s.
//Debimos haber calculado la función de error desde antes de llamar esta función.
void Aparece(){

	//Ya que no hemos matcheado nada, empezamos en el estado inicial
	int pos = 0;

	//Vamos caracter por caracter
	for(int i = 0; i < s.size(); i++){

		//Buscamos sobre 't' el primer caracter que sea igual al siguiente de 's'
		//Aplica la misma regla de cuando llegamos a -1, es decir, dejamos de movernos
		//hacia atrás.
		while(pos >= 0 && s[i] != t[pos] )
			pos = FE[pos]; //De nuevo usamos la función de error

		//Ya que encontramos un caracter igual, o llegamos a -1, avanzamos sobre
		//el "autómata", que en sí es un arreglo
		pos++;

		//Preguntamos si ya procesamos todos los caracteres de t
		if(pos == t.size()){
			//Si es así, es porque en i hemos pasados por todos los caracteres
			//Por lo tanto t termina en la posición i.
			//Así, si termina en i , entonces inicio en i - |t| + 1.
			cout << i - t.size() + 1 << '\n';

			//Al estar en el último estado, no habrá nada que acepte el "autómata",
			//entonces, eventualmente se moverá con la función de errro. Por lo tanto
			//no hay problema con moverse desde este punto.
			pos = FE[pos];

		}
	}
}

int main() {
    cin>>s;
    cin>>t;
    FuncionError();
    Aparece();
    return (0);
}



Measured memory_bytes: 3996
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<iterator>
#include<iomanip>
#include<string>
using namespace std;

long long int sum(long long int x)
{
    return x*(x+1)/2;
}

int main()
{
    long long int n;
    cin>>n;
    cout<<sum(n)+15*sum(n/15)-3*sum(n/3)-5*sum(n/5);
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin >> n  ;
  if(n==1){
    cout << "Hello World";
  }
   if(n==2){
    cin >> a;
    cin >> b;
    cout << a+b;
  }
  return 0;
}

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

int main(){

    int k,s;

    cin >> k >> s;
    ll ans=0;

    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            int z=s-x-y;
            if(z>=0&&z<=k){
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  string s;
  cin>>s;
  int ans=700;
  rep(i,3) if(s[i]=='o') ans+=100;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  int D, T, S;
  cin >> D >> T >> S;
  if (S*T>=D) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
import numpy as np
n,k=map(int,input().split())
h=np.array(list(map(int,input().split())))
dp=np.zeros(n,dtype="int32")
for i in range(1,n):
    start=0 if k>i else i-k
    dp[i]=np.min(dp[start:i]+np.abs(h[i]-h[start:i]))
print(dp[-1])

Measured memory_bytes: 22860
import sys
sys.setrecursionlimit(10**6)

N = int(input())
symbols = list("357")

def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in symbols) else 0
    for c in symbols:
        ret += dfs(s + c)
    return ret

print(dfs("0"))

Measured memory_bytes: 3316
from collections import deque

H,W=map(int,input().split())
S=[input() for _ in range(H)]

paint=((1,0),(-1,0),(0,1),(0,-1))
que=deque([])

dark=[[0]*W for _ in range(H)] # 1が黒、0はまだ白

for i in range(H): # 初期化(最初に黒いマスをdarkリストに入れて、キューに入れる。)
    for j in range(W):
        if S[i][j]=='#':
            que.append((i,j,0))
            dark[i][j]=1
ans=0
while len(que)>0:
    di,dj,c=que.popleft()
    
    for pi,pj in paint:
        ni,nj=pi+di,pj+dj # 移動先がni,nj
        if 0<=ni<H and 0<=nj<W and dark[ni][nj]==0:
            dark[ni][nj]=1
            que.append((ni,nj,c+1))
            ans=c+1
print(ans)

Measured memory_bytes: 135388
#include <iostream>
#include <string>

int main() {
	std::string A, B, C;
	std::cin >> A >> B >> C;

	if(A.back() == B.front() && B.back() == C.front()) {
		std::cout << "YES" << std::endl;
	} else {
		std::cout << "NO" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] h = new int[n];
    int str = 0;
    int max = 0;
    for(int i = 0; i < n; i++){
      h[i] = sc.nextInt();
      if(i != 0 && h[i] <= h[i - 1]){
        str++;
        if(i == n - 1){
          max = Math.max(max , str);
        }
      }else if(i != 0 && h[i] > h[i - 1] && str != 0){
        max = Math.max(max , str);
        str = 0;
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 49492
!-----------------------startmain-------------------------
program atcoder
    implicit none
    integer(8) n,p,i,j,pp,ans
    read*,n,p
    ans = 1
    pp = p;
    i = 2
    do while(i*i<=p)
        j = 0
        do while(mod(pp,i)==0)
            j = j + 1
            pp = pp/i
        end do
        do while(j>=n)
            j = j - n
            ans = ans * i
        enddo
        i = i+1
    enddo
    if(n==1)then
        ans = ans*pp
    endif
    write(*,'(I0)')ans
!-----------------------endmain---------------------------
contains
!----------------------functions--------------------------

!----------------------functions--------------------------
end program atcoder


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    double L[10];
    double V1, V2;
    double meet_pos, railway_lenth;
    int cnt, output_cnt;
    int output[50];
    
    output_cnt = 0;
    /*Input and process*/
    while(scanf("%lf,", &L[0]) != EOF){
    	for(cnt = 1; cnt < 10; cnt++)
			scanf("%lf,", &L[cnt]);
		scanf("%lf,%lf", &V1, &V2);
    	/*Calculate meet position*/
    	for(cnt = 0, railway_lenth = 0; cnt < 10; cnt++)
			railway_lenth += L[cnt];
    	meet_pos = railway_lenth * V1 / (V1 + V2);
    	for(cnt = 0, railway_lenth = 0; railway_lenth < meet_pos; cnt++)
			railway_lenth += L[cnt];
    	output[output_cnt++] = cnt;
    }
    /*Output*/
    for(cnt = 0; cnt < output_cnt; cnt++)
		printf("%d\n", output[cnt]);
    
    return 0;
} 

Measured memory_bytes: 624
/* Author rumoisen */
/* date 2018/10/08 */

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

using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;
using namespace std;

int main()
{
    string a,b;
    cin>>a>>b;
    int x=stoi(a+b);
    bool ans=false;
    for(int i=1;i<1000;i++){
        if(i*i==x) ans=true;
    }
    if(ans) yes();
    else no();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N;
vector<vector<int>> G;

int f(int i) {
  vector<int> d(N, N * N);
  d[i] = 1;
  queue<int> q;
  q.push(i);

  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v : G[u]) {
      if (d[v] < d[u] - 1) return -1;
      if (d[v] == d[u] - 1 || d[v] == d[u] + 1) continue;
      if (d[v] == d[u]) return -1;
      assert(d[v] == N * N);
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  return *max_element(all(d));
}

int main() {
  cin >> N;
  G.resize(N);
  rep(i, N) rep(j, N) {
    char c;
    cin >> c;
    if (c == '1') {
      G[i].push_back(j);
    };
  }

  int ans = -1;
  rep(i, N) ans = max(ans, f(i));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    H = int(readline())
    W = int(readline())

    print((N - H + 1) * (N - W + 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61912
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

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

ll lcm(ll a, ll b){
    ll tmp = gcd(a, b);
    //cout << tmp << endl;
    tmp = a / tmp;
    tmp = tmp * b;
    return tmp;
}

int main() {

    ll N, M;
    cin >> N  >> M;

    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    ll c = 1;
    while(A[0] % c == 0) c *= 2;
    c /= 2;

    ll tmp = 1;
    REP(i, N){
        if (A[i] % c != 0 || A[i] % (2 * c) == 0){
            cout << 0 << endl;
            return 0;
        }
        tmp = lcm(tmp, A[i]);
        
        if (tmp > 2 * M){
            cout << 0 << endl;
            return 0;
        }
        
        //cout << tmp << endl;
    }
    ll ans = (M + tmp / 2) / tmp;
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import sys

S = input()

words = ['dream', 'dreamer', 'erase', 'eraser']

while len(S) > 0:
    if len(S) < 5:
        print('NO')
        sys.exit(0)
    no_match = True
    for word in words:
        if S[-3] == word[-3]:
            if len(S) < len(word) or S[-len(word):] != word:
                print('NO')
                sys.exit(0)
            S = S[:-len(word)]
            no_match = False
            break
    if no_match:
        print('NO')
        sys.exit(0)

print('YES')

Measured memory_bytes: 9248
import java.util.*;
import javax.lang.model.util.ElementScanner6;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 入力
        int h = sc.nextInt();
        int w = sc.nextInt();
        int n = sc.nextInt();

        // 処理
        int out = 0;
        int l = h > w ? h : w;
        int syo = n / l;
        int amari = n % l;
        out = syo + (amari != 0 ? 1 : 0);

        // 出力
        System.out.println(out);
    }
}

Measured memory_bytes: 22996
s=input()
if len(s)%2==1:
    s=s[:-1]
s_len=len(s)
for i in range(1,(s_len+1)//2):
    s=s[:-2]
    if s[:s_len//2-i]==s[s_len//2-i:]:
        print(s_len-2*i)
        break

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

void fnInput(vector<int>& rvnNum)
{
  int nSize;
  cin >> nSize;
  rvnNum.resize(nSize);

  for (int& rnElm : rvnNum)
    cin >> rnElm;
}

int64_t fnSignChgTimes(const vector<int>& cnrvnNum)
{ 
  vector<int64_t> vnTimes(2);

  for (int nParity = 0; nParity < vnTimes.size(); nParity++)
  {
    int64_t nTimes = 0;
    int64_t nSum   = 0;
    for (int n = 0; n < cnrvnNum.size(); n++)
    {
      nSum += cnrvnNum[n];
      if (n % 2 == nParity)
        if (nSum > 0);
        else
        {
          nTimes += 1 - nSum;
          nSum = 1;
        }
      else
        if (nSum >= 0)
        {
          nTimes += 1 + nSum;
          nSum = -1;
        }
        else;
    }
    vnTimes[nParity] = nTimes;
  }
  auto itElm = min_element(begin(vnTimes), end(vnTimes));
  return *itElm;
}

int main()
{
  vector<int> vnNum;

  fnInput(vnNum);
  cout << fnSignChgTimes(vnNum) << endl;

  return 0;
}

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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int a, b, c, d; cin >> a >> b >> c >> d;
  cout << max(a * b, c * d) << '\n';
  return 0;
}


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


int main(){
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    ll t,i,q,j,x,y,k,temp,temp2,l,tt,n,m,sum=0;
    // cin >> t;
    
    // while(t--){
        cin >> n;
        // vector <ll> a(n);
        if(n>=1800) cout << "1";
        else if(n>=1600) cout << "2";
        else if(n>=1400) cout << "3";
        else if(n>=1200) cout << "4";
        else if(n>=1000) cout << "5";
        else if(n>=800) cout << "6";
        else if(n>=600) cout << "7";
        else if(n>=400) cout << "8";
    // }

}


Measured memory_bytes: 3632
// B - Picture Frame
#include <bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<(n);++i)

int main(){
	int H,W; cin>>H>>W;

	vector<string> A(H);
	rp(i,H) cin>>A[i];

	cout<<"#";rp(j,W) cout<<"#";puts("#");
	rp(i,H)cout<<"#"<<A[i]<<"#\n";
	cout<<"#";rp(j,W) cout<<"#";puts("#");

}

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

typedef pair<int, int> card;

int main() {
    vector<card> deck;
    char suit;
    int rank;
    
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
            deck.push_back(make_pair(i, j));
        }
    }
    
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> suit >> rank;
        if (suit == 'S') {
            remove(deck.begin(), deck.end(), make_pair(0,rank - 1));
        } else if (suit == 'H') {
            remove(deck.begin(), deck.end(), make_pair(1,rank - 1));
        } else if (suit == 'C') {
            remove(deck.begin(), deck.end(), make_pair(2,rank - 1));
        } else if (suit == 'D') {
            remove(deck.begin(), deck.end(), make_pair(3,rank - 1));
        }
    }
    
    sort(deck.begin(), deck.end());
    
    for (int i = 0; i < (52 - n); i++) {
        if (deck[i].first == 0) {
            cout << "S " << deck[i].second + 1 << endl;
        } else if (deck[i].first == 1) {
            cout << "H " << deck[i].second + 1 << endl;
        } else if (deck[i].first == 2) {
            cout << "C " << deck[i].second + 1 << endl;
        } else if (deck[i].first == 3) {
            cout << "D " << deck[i].second + 1 << endl;
        }
    }
}


Measured memory_bytes: 3132
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin>>s;
  int len=s.size();
  string ans="";
  int count=0;
  for(int i=0;i<len;i++){
    if(s[i]=='1'){
      ans+=s[i];
      count++;
    }
    if(s[i]=='0'){
      ans+=s[i];
      count++;
    }
    if(s[i]=='B'){
      if(count!=0){
        ans.pop_back();
        count--;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

const ll INF = 1e15;
signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int n; cin >> n;
    vector<pair<ll,P>> v;
    
    ll dst[n][n],d[n][n];
    rep(i,n)rep(j,n)d[i][j]=INF;
    rep(i,n)d[i][i]=0;
    rep(i,n){
        rep(j,n){
            ll x; cin >> x;
            if(i<j) v.pb({x,{i,j}});
            dst[i][j]=dst[j][i]=x;
        }
    }
    sort(ALL(v));
    ll ans=0;
    rep(i,v.size()){
        //pqに直接作る必要がARUKA
        int p=v[i].se.fi,q=v[i].se.se;
        bool ok=1;
        rep(j,n){
            if(d[p][j]+d[j][q]<dst[p][q]){//moudame
                cout << -1 <<endl;
                return 0;
            }else if(d[p][j]+d[j][q]==dst[p][q]){ //exist
                d[p][q]=d[q][p]=dst[p][q];
                ok=0;
            }
        }
        if(ok){
            ans+=v[i].fi;
            d[p][q]=d[q][p]=v[i].fi;
        }
    }
    cout<<ans<<endl;
}



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

const int N = 1e3 + 5;
int h, n, a[N], b[N], dp[10005];

int f(int strength) {
	if(strength <= 0) {
		return 0;
	}
	if(dp[strength] != -1) 
		return dp[strength];
	int ret = 1e9 + 7;
	for(int i=0; i<n; ++i) {
		ret = min(ret, f(strength - a[i]) + b[i]);
	}
	dp[strength] = ret;
	return ret;
}

int main() {
	cin >> h >> n;
	memset(dp, -1, sizeof(dp));
	for(int i=0; i<n; ++i) 
		cin >> a[i] >> b[i];
	cout << f(h) << "\n"; 
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<cmath>
#include<cstdio>
#define PI 3.14159265358979

using namespace std;

int main(){
  double a,b,c;
  cin >> a >> b >> c;
  double rad = c * (PI/180);
  double S,L,h;
  S = 0.5 * a * b * sin(rad);
  printf("%.8lf\n",S);
  double d = a * a + b * b - 2 * a * b * cos(rad);
  L = a + b + sqrt(d);
  printf("%.8lf\n",L);
  h = b * sin(rad);
  printf("%.8lf\n",h);
  return 0;
}


Measured memory_bytes: 3476
#include <stdio.h>

int main(void)
{
	int i, n;
	long sum, max, a;
	
	while (scanf("%d", &n), n != 0){
		sum = 0;
		max = -10000000;
		for (i = 0; i < n; i++){
			scanf("%ld", &a);
			sum += a;
			if (sum > max) max = sum;
			if (sum < 0) sum = 0;
		}
		
		printf("%ld\n", max);
	}
	
	return 0;
}

Measured memory_bytes: 600
from collections import Counter

N = int(input())
V = list(map(int, input().split()))

if len(set(V)) == 1:
    print(len(V)//2)
    exit()

V_odd = [i for i in V[::2]]
V_even = [i for i in V[1::2]]
V_odd_counter = Counter(V_odd)
V_even_counter = Counter(V_even)

vodd = V_odd_counter.most_common()
veven = V_even_counter.most_common()
vlen = len(V)
while True:
    if vodd[0][0] != veven[0][0]:
        print(vlen - vodd[0][1] - veven[0][1])
        exit()
    else:
        print(min(vlen - vodd[1][1] - veven[0][1],
                    vlen - vodd[0][1] - veven[1][1]))
        exit()

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int D, G;
    cin >> D >> G;
    int p[10], c[10];
    for(int i=0;i<D;i++) cin >> p[i] >> c[i];

    ll ans = INT64_MAX;
    for(int i=0;i<(1<<D);i++){
        ll cnt = 0;
        ll pt = 0;
        for(int j=0;j<D;j++){
            if(i&(1<<j)){
                cnt += p[j];
                pt += (j+1)*100*p[j] + c[j];
            }
        }
        if(pt >= G){
            ans = min(ans, cnt);
            goto next;
        }
        for(int j=D-1;j>=0;j--){
            if((i&(1<<j))==0){
                int n = (G-pt+(j+1)*100-1)/((j+1)*100);
                n = max(0, min(p[j]-1, n));
                cnt += n;
                pt += n*(j+1)*100;
            }
            if(pt >= G){
                ans = min(ans, cnt);
                goto next;
            }
        }
        next:;
    }

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

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

typedef long long ll;
const int M = 1010, N = 2, MOD = 1000 * 1000 * 1000 + 7;

int sum(int a, int b) {
	a += b;
	if (a < 0)
		a += MOD;
	else if (a >= MOD)
		a -= MOD;
	return a;
}
void _sum(int &a, int b) {
	a = sum(a, b);
}
int mul(int a, int b) {
	return 1LL * a * b % MOD;
}
void _mul(int &a, int b) {
	a = mul(a, b);
}

struct MAT {
	int a[N][N];
	MAT(int x = 1) {
		for (int i = 0; i < N; i++)
			for (int j = 0; j < N; j++)
				a[i][j] = (i ^ j? 0: x);
	}
	int* operator[](int x) {
		return a[x];
	}
	MAT operator*(MAT b) {
		MAT res(0);
		for (int i = 0; i < N; i++)
			for (int j = 0; j < N; j++)
				for (int k = 0; k < N; k++)
					_sum(res[i][k], mul(a[i][j], b[j][k]));
		return res;
	}
	void operator*=(MAT b) {
		*this = *this * b;
	}
};
MAT power(MAT a, ll b) {
	MAT res;
	while (b) {
		if (b & 1)
			res *= a;
		a *= a;
		b >>= 1;
	}
	return res;
}

ll n, m, k;
string s[M];

void input() {
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++)
		cin >> s[i];
}

int solve() {
	if (k <= 1)
		return 1;
	k--;

	int right = 0, up = 0, cnt = 0;
	for (int i = 0; i < n; i++)
		for (char c: s[i])
			cnt += (c == '#');
	for (int i = 0; i < n; i++)
		right += (s[i][0] == s[i][m - 1] && s[i][0] == '#');
	for (int j = 0; j < m; j++)
		up += (s[0][j] == s[n - 1][j] && s[0][j] == '#');

	if (up == 0 && right == 0) {
		MAT x(0);
		x[0][1] = cnt;
		x[1][0] = 1;
		return power(x, 2 * k)[0][0];
	}
	if (up && right)
		return 1;
	MAT x(0);
	x[1][1] = cnt;
	if (up) {
		x[0][0] = up;
		for (int i = 0; i < n - 1; i++)
			for (int j = 0; j < m; j++)
				if (s[i][j] == s[i + 1][j] && s[i][j] == '#')
					x[0][1]++;
	}
	else {
		x[0][0] = right;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m - 1; j++)
				if (s[i][j] == s[i][j + 1] && s[i][j] == '#')
					x[0][1]++;
	}
	x = power(x, k);
	return sum(x[1][1], -x[0][1]);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	input();
	cout << solve();
}


Measured memory_bytes: 1280
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        int count5 = 0;
        int count7 = 0;

        if(A == 5) count5++;
        else if(A == 7) count7++;

        if(B == 5) count5++;
        else if(B == 7) count7++;

        if(C == 5) count5++;
        else if(C == 7) count7++;

        if(count5 == 2 && count7 == 1) System.out.println("YES");
        else System.out.println("NO");
    }
}


Measured memory_bytes: 35892
# -*- coding: utf-8 -*-

# スペース区切りの整数の入力
h, w, m = map(int, input().split())

h_list = [0]*h
w_list = [0]*w

# h_w_list = [[0 for j in range(w)] for i in range(h)]
# h_w_list = []
h_w_list = set()

for zzz in range(m):
  # print("---")
  bom_h, bom_w = map(int, input().split())
  # print(bom_h, bom_w)
  h_list[bom_h-1] += 1
  w_list[bom_w-1] += 1

  # h_w_list[bom_h-1][bom_w-1] = 1
  # h_w_list.append([bom_h, bom_w])
  h_w_list.add((bom_h, bom_w))

mh = max(h_list)
mw = max(w_list)
h_max_indexs = [i for i, v in enumerate(h_list) if v == mh]
w_max_indexs = [i for i, v in enumerate(w_list) if v == mw]

double_chance = False
# print("---")
for h_index in h_max_indexs:
  if double_chance:
    break
  for w_index in w_max_indexs:
    if double_chance:
      break
    # chance = h_w_list.count([h_index + 1, w_index + 1]) == 0
    chance = (h_index + 1, w_index + 1) not in h_w_list

    if chance:
      double_chance = True


if double_chance:
  result = mh + mw
else:
  result = mh + mw -1

print(result)


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

using namespace std;

using int64 = long long;

int64 Max(const vector<int64>& xs) {
  int64 value = INT64_MIN;
  for (int64 x : xs) value = max(x, value);
  return value;
}

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

  int n;
  int64 cap;
  cin >> n >> cap;
  vector<int64> weights(n);
  vector<int64> values(n);
  for (int i = 0; i < n; i++) {
    cin >> weights[i];
    cin >> values[i];
  }

  vector<vector<int64>> dp(n + 1, vector<int64>(cap + 1, -1));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= cap; j++) {
      if (dp[i][j] < 0) continue;
      if (j + weights[i] <= cap) {
        dp[i + 1][j + weights[i]] =
            max(dp[i + 1][j + weights[i]], dp[i][j] + values[i]);
      }
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
    }
  }
  cout << Max(dp[n]) << endl;
}


Measured memory_bytes: 80256
/*/ Author: KaySeeKay /*/

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

/*/---------------------------Defines-----------------------------------------/*/

#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)	
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;	
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
inline int add(int x, int y, int mod) {
   if (y >= mod) y %= mod;
   if (x >= mod) x %= mod;
   x  += y;
   return (x >= mod ? x - mod : x);
} 
inline int mul(int x, int y, int mod) {
  if (x >= mod) x %= mod;
  if (y >= mod) y %= mod;
  return (x*y) % mod;
}
inline int sub(int x, int y, int mod) {
  x -= y;
  if (x + mod <= 0) {
	x %= mod;
  }
  return (x < 0 ? x+mod : x);
}
/*/-----------------------------Code begins----------------------------------/*/


signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		fn1{
			cin >> ar[i];
			dp[i]=dp[i-1]+ar[i];
		}
		int ans =0 ;
		fn1{
			int right = dp[n] - dp[i];
			int cur=right;
			cur=mul(cur,ar[i],MOD);
			ans=add(ans,cur,MOD);
		}
		cout <<ans;

	
	
	}
	return 0;
}

Measured memory_bytes: 6744
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int x = in.nextInt();
        System.out.println(360 / gcd(360, x));
    }
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
class BIT {
public:
  BIT(int n_)
  {
    n = n_;
    bit.resize(n + 1, 0);
  }
  T sum(int i)
  {
    assert(0 <= i);
    return _sum(i + 1);
  }
  void add(int i, T x)
  {
    assert(0 <= i);
    return _add(i + 1, x);
  }
private:
  vector<T> bit;
  int n;
  T _sum(int i)
  {
    T s = 0;
    while (i > 0) {
      s += bit[i];
      i -= i & -i;
    }
    return s;
  }
  void _add(int i, T x)
  {
    while (i <= n) {
      bit[i] += x;
      i += i & -i;
    }
    return ;
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<pair<char, int>> v(n * 2);
    each (i, v) {
      cin >> i.first >> i.second;
      --i.second;
    }

    vector<int> w(n);
    vector<int> b(n);
    for (int i = 0; i < v.size(); ++i) {
      if (v[i].first == 'B') b[v[i].second] = i;
      else w[v[i].second] = i;
    }

    const int inf = 1 << 27;
    const int N = 2000 + 5;
    static int dp[N][N];
    fill(&dp[0][0], &dp[N - 1][N - 1] + 1, inf);
    dp[0][0] = 0;

    BIT<int> bit(2 * n + 5);
    for (int i = 0; i < v.size(); ++i) {
      bit.add(i, 1);
    }

    for (int i = 0; i <= n; ++i) {
      BIT<int> tmp = bit;
      for (int j = 0; j <= n; ++j) {
        const int k = i + j;
        if (i < n) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (w[i] ? bit.sum(w[i] - 1) : 0));
        if (j < n) dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (b[j] ? bit.sum(b[j] - 1) : 0));
        if (j < n) bit.add(b[j], -1);
      }
      bit = tmp;
      if (i < n) bit.add(w[i], -1);
    }

    cout << min(dp[n - 1][n], dp[n][n - 1]) << endl;
  }

  return 0;
}


Measured memory_bytes: 16000