akhauriyash/Code-Regression huggingface dataset:
from itertools import count
def get_weed(h):
    d = [h[i + 1] - h[i] for i in range(3)]
    if d[0] == d[1] == d[2]:
        for hi, expect in zip(h, count(h[0], d[0])):
            if hi != expect:
                return hi

    for i in range(4):
        hh = h[:i] + h[i + 1:]
        d = [hh[i + 1] - hh[i] for i in range(3)]
        if d[0] == d[1] == d[2]:
            return h[i]

import sys
f = sys.stdin

while True:
    n = int(f.readline())
    if n == 0:
        break
    h = list(map(int, f.readline().split()))
    print(get_weed(h))

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

int main(){
  long long a, b, v, w, t;
  cin >> a >> v >> b >> w >> t;
  
  bool ok;
  long long k = v - w;
  if(k <= 0) ok = false;
  else if((abs(b-a+k-1)) / k <= t) ok = true;
  else ok = false;
  
  if(ok) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3620
import java.util.*;

class Main {
	Scanner sc;
	
	void calc() {
		sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s = sc.next();
		
		StringBuilder ans = new StringBuilder();
		for (int i = 0; i < s.length(); i++)
			ans.append( (char) ((s.charAt(i)-'A'+N)%26+'A') );
		System.out.println(ans.toString());
	}

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

Measured memory_bytes: 23892
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
	int n;
	cin>>n;
	cout<<(n-2)*180<<endl;
}

Measured memory_bytes: 768
// Tenki
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

int main()
{
    string S, T;

    cin >> S;
    cin >> T;
    int cnt = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == T[i]) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 888
def main():
    #input data
    import sys
    input = lambda:sys.stdin.readline().strip()
    
    N,A,B = map(int,input().split())
    mod=10**9+7
    #solve
    #二項係数の和=2**n
    #2**n-1-nCa-nCb
    def pow(x, y, mod):
        res = 1
        if y > 0:
            res = pow(x, y // 2, mod)
            if y % 2 == 0:
                res = (res * res) % mod
            else:
                res = (((res * res) % mod) * x) % mod
        return res
        
    def cmb(n, r, mod=10**9+7):
        c = 1
        m = 1
        r = min(n - r, r)
        for i in range(r):
            c = c * (n - i) % mod
            m = m * (i + 1) % mod
        return c * pow(m, mod - 2, mod) % mod
                
    ans = pow(2,N,mod)-1-cmb(N,A,mod)-cmb(N,B,mod)
    print(ans%mod)

if __name__=='__main__':
    main()

Measured memory_bytes: 9156
#include<bits/stdc++.h>
#define MAX 101
using namespace std;

int X[8]={0,1,-1,0,1,1,-1,-1};
int Y[8]={1,0,0,-1,1,-1,1,-1};
int h,w;
char grid[MAX][MAX];

bool in(int a,int b){
  if(a<0 || b<0 || h<=a || w<=b)return false;
  return true;
}

int main()
{
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)cin>>grid[i][j];
  }
  
  int ans=0;
  for(int i=1;i<h;i++){
    for(int j=0;j<w;j++){
      if(grid[i][j]!='-')continue;
      bool flag=true;
      for(int k=0;k<8;k++){
        int a=i+Y[k],b=j+X[k];
        if(!in(a,b))continue;
        if(grid[a][b]=='x')flag=false;
      }
      int sum=0;
      if(in(i,j-1) && grid[i][j-1]=='o')sum++;
      if(in(i,j+1) && grid[i][j+1]=='o')sum++;
      if(sum!=0)flag=false;
      if(flag)ans++;
    }
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
const ll MOD=1000000007;

int main(){
  ll N,K;
  cin >> N >> K;
  ll ans=0;

  vector<ll> inv(2*N+2,0);
  vector<ll> fac(2*N+2,0);
  vector<ll> finv(2*N+2,0);
  inv[0]=inv[1]=1;
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  for(int i=2;i<=2*N+1;i++){
    fac[i]=fac[i-1]*i; fac[i]%=MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]; finv[i]%=MOD;
    //cout << i << " " << fac[i]*finv[i]%MOD << endl;
  }

  for(int i=0;i<min(N,K+1);i++){
    ll ansi=1;
    ansi*=fac[N]; ansi%=MOD;
    ansi*=finv[N-i]; ansi%=MOD;
    ansi*=finv[i]%MOD; ansi%=MOD;
    ansi*=fac[N-1]; ansi%=MOD;
    ansi*=finv[N-1-i]; ansi%=MOD;
    ansi*=finv[i];; ansi%=MOD;
    ans+=ansi; ans%=MOD;
    //cout << i << " " << ansi << endl;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"
#include "string"

int32_t main(){
	boost;
	int r, g, b, k;
	cin >> r >> g >> b >> k;
	while(k > 0 && g <= r) {
		g *= 2;
		k--;
	}

	while(k > 0 && b <= g) {
		b *= 2;
		k--;
	}

	if(g > r && b > g)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3640
n=int(input())
F=[list(map(int,input().split())) for _ in range(n)]
P=[list(map(int,input().split())) for _ in range(n)]
ans=-float('inf')
for i in range(1,1<<10):
    OPEN=[0]*n
    for j in range(10):
        if (i>>j)&1:
            for k in range(n):
                if F[k][j]==1:
                    OPEN[k]+=1
    tmp=0
    for l in range(n):
        tmp+=P[l][OPEN[l]]
    ans=max(ans,tmp)
print(ans)

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

#define endl "\n"
#define INF 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    int n, k;
    cin >> n >> k;
    int base = k;
    int times = 0;
    while (n) {
        n -= n % base;
        base *= k;
        times++;
    }
    cout << times << endl;

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int n,c;
    cin>>n;
    if(n%2) c=(n/2)+1;
    else c=n/2;
    double d=c/(n*1.0);
    cout<<fixed<<setprecision(10)<<d<<endl;
    return 0;
}


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

int main()
{
	ios::sync_with_stdio(false);
	
	int n;
	cin>>n;
	string blue[n];
	
	for(int i=0;i<n;i++)
		cin>>blue[i];
	
	int m;
	cin>>m;
	string red[m];
	
	for(int i=0;i<m;i++)
		cin>>red[i];
	
	int ans=0;
	
	for(int i=0;i<n;i++)
	{
		string word=blue[i];
		int count=0;
		
		for(int j=0;j<n;j++)
			if(blue[j]==word)
				count++;
		for(int j=0;j<m;j++)
			if(red[j]==word)
				count--;
		
		ans=max(ans,count);
	}
	
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(void)
{
	while(1)
	{
		string s;
		cin>>s;
		if(cin.eof())break;
		char ans[900];
		int c=0;
		for(int i=0;i<s.length();i++)
		{
			if(s[i]!='@')ans[c++]=s[i];
			else{
				i++;
				for(int j=0;j<s[i]-'0';j++)
				{
					ans[c++]=s[i+1];
				}
				i++;
			}
		}
		ans[c]='\0';
		cout<<ans<<endl;
	}
}

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

#define M_PI 3.14159265358979323846

using namespace std;

//typedef
//-------------------------#include <bits/stdc++.h>

#define M_PI 3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}
inline int readInt()
{
    int x;
    scanf("%d", &x);
    return x;
}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a) * (a))
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;

#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const int INF = 2147483647;

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

    int N;
    cin >> N;

    int px = 0, py = 0;
    bool ok = true;
    int pt = 0;
    for (int i = 0; i < N; i++)
    {
        int t, x, y;
        cin >> t >> x >> y;

        {
            int sax = abs(px - x);
            int say = abs(py - y);
            int sat = abs(t - pt);
            if (sax + say <= sat && (sax + say) % 2 == sat % 2)
            {
                px = x;
                py = y;
                pt = t;
            }
            else
            {
                ok = false;
            }
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long n,m;
cin>>n;
if(360%n==0)
    cout<<360/n<<endl;
 else
  {
    m=360;
      while(m%n!=0)
      {
          m+=360;
          if(m%n==0)
          {
              break;
          }
      }
cout<<m/n<<endl;

  }
 return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int n; cin >> n;
    int tmp = n*(n+1);
    tmp /= 2;
    cout << tmp << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int fx4[] = {1 , -1 , 0 , 0};
int fy4[] = {0 , 0 , 1 , -1};
int Kfx[]= {-2,-2,2,2,1,1,-1,-1}; ///knight move x - exis
int Kfy[]= {1,-1,1,-1,2,-2,2,-2}; ///knight move y- exis
int fx8[]= {1,1,1,0,0,-1,-1,-1};
int fy8[]= {0,1,-1,1,-1,0,1,-1};
#define ll long long int
#define pii pair<int,int>
#define llu unsigned long long
#define inf 1<<28
#define gama 0.57721566490
#define PI              acos(-1.0)
#define INF             0x7fffffff
#define MOD             1000000007
#define EPS             1e-7
#define all(r)(r).begin(),(r).end()
/*
bool status[mx];
void sieve(){
   long long int  i,j;
    for(i=2;i<=mx;i++)
    {
        status[i]=0;
    }
    for( i=2;i<=sqrt(mx);i++){
        if(status[i]==0)
        {
            for(j=i*i;j<=mx;j+=i){
                status[j]=1;
            }
        }
    }
}*/
ll BM( ll a , ll b , ll m )
{
    if ( b == 0 ) return 1 ;
    ll x = BM(a,b/2,m);
    x = (( x % m) * (x % m))%m;

    if( b % 2 ) x = (( x % m) * (a %m)) % m ;
    return x ;
}
#define dd double
#define sc scanf
#define pr printf
#define VI vector<int>
#define VS vector<string>
#define VC vector<char>
#define VLL vector<long long int>
#define FILE freopen("input.txt","rt",stdin); freopen("output.txt","w",stdout);
#define p_b push_back
#define mem(x,y) memset(x,y,sizeof(x))
#define F(i,a,b) for(i=a;i<=b;i++)
#define sc1(a) scanf("%d",&a)
#define scL1(a) scanf("%lld",&a)
#define scL2(a,b) scanf("%lld%lld",&a,&b)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define fori(N)          for(int i = 0; i<(N); i++)
#define forj(N)         for(int j = 0; j<(N); j++)
#define fork(N)         for(int k = 0; k<(N); k++)
#define forl(N)         for(int l = 0; l<(N); l++)
#define ford(N)         for(int d = 0; d<(N); d++)
#define fori1(N)          for(int i = 1; i<=(N); i++)
#define forj1(N)         for(int j = 1; j<=(N); j++)
#define fork1(N)         for(int k = 1; k<=(N); k++)
#define ford1(N)         for(int d = 1; d<=(N); d++)
#define sqr(x)           (x)*(x)
#define TEST int test,te=0;cin>>test;
#define segment_tree int l=(n*2),r=(n*2)+1,mid=(l+r)/2
#define Mx 100005
#define mx 10005

int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);///Beware of use it, if u use it dont use scanf or printf
    int n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    string r="";
    for(int i=0;i<n;i++){
	r+=a[i];
	r+=b[i];}
    cout<<r<<endl;
}


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

using namespace std;

vector<int> G[9];
int N, M;

int solve2(int s, vector<int> state){
  int result = 0;
  int ok = 1;
  for(int i = 1; i <= N; i++){
    if(state[i] == 0){
      ok = 0;
      break;
    }
  }
  if(ok == 1) return 1;

  for(int i = 0; i < G[s].size(); i++){
    int to = G[s][i];
    if(state[to] == 1)  continue;
    else {
      vector<int> state2(state);
      state2[to] = 1;
      result += solve2(to, state2);
    }
  }
  return result;
}

void solve(){
  vector<int> state(9, 0);
  state[1] = 1;
  cout << solve2(1, state) << endl;
}


int main(){
  cin >> N >> M;

  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  solve();

}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	int n; cin>>n;
	vector<pii> a(n);
	rep(i,n)
		cin>>a[i].first>>a[i].second;
	
	vvi dp(n,vi(n,1<<29));
	rep(i,n)
		dp[i][i]=0;
	for(int i=n;i--;){
		for(int j=i+1;j<n;j++){
			for(int k=i;k<j;k++){
				int mul=a[i].first*a[k].second*a[k+1].first*a[j].second;
				dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+mul);
			}
		}
	}
	
	cout<<dp[0][n-1]<<endl;
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define num(a) a-'0'
#define maxself(a,b) if(b>a)a=b
#define minself(a,b) if(b<a)a=b;
#define debug(x) cout<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define vl vector<long long int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"	
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF=1e9+7;
ll INF=1e11;

void solve(){
	int n;
	cin>>n;
	vi b(n-1);
	rep(i,0,n-1){
		cin>>b[i];
	}
	ll sum=0;
	sum+=b[0];
	sum+=b[n-2];
	for(int i=1;i<n-1;i++){
		sum+=min(b[i],b[i-1]);
	}
	cout<<sum<<ln;
}

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

Measured memory_bytes: 3636
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define endl '\n'
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}


signed main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    string s;
    cin >> s;

    bool f[128] {};
    for (char c : s) f[c] = true;

    auto unusedMinChar = [&f](char c) {
        for (; f[c]; ++c);
        return c;
    };

    if (s == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
    }
    else if (s.length() >= 26) {
        set<char> buf;

        for (int i = s.length() - 1;
                i >= 1 && s[i-1] > s[i];
                --i, buf.emplace(s.back()), s.pop_back());


        buf.emplace(s.back());
        s.pop_back();
        s.back() = *buf.upper_bound(s.back());
        cout << s << endl;
    }
    else {
        cout << s << unusedMinChar('a') << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N=int(input())
W=list(map(int,input().split()))
#print(lis)
#W.sort(reverse=True)
min=20000
sum=0
sum2=0
for i in range(N):
    sum=sum+W[i]
for i in range(N):
    sum=sum-W[i]
    sum2=sum2+W[i]
    if (abs(sum-sum2)<min):
        min=abs(sum-sum2)
print(min)

Measured memory_bytes: 38384
#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>;

const int INF = 1001001001;

int a[12][12];

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    rep(i,n) {
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }

    int ans = INF;
    rep(s,1 << n) {
        int cost = 0;
        vector<int> d(m);
        rep(i,n) {
            if(s >> i & 1) {
                cost += c[i];
                rep(j,m) d[j] += a[i][j];
            }
        }
        bool ok = true;
        rep(j,m) if(d[j] < x) ok = false;
        if(ok) ans = min(ans, cost);
    }

    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
vector<int> v[100005];
int n,m,f[100005],vis[100005];
void dfs(int x){
//	for(int i=1;i<=n;i++){
//		cout<<f[i]<<" ";
//	}
//	cout<<endl;
	if(vis[x]==1){
		return;
	}
	vis[x]=1;
	if(v[x].size()==0){
		f[x]=0;
		return ;
	}
	for(int i=0;i<v[x].size();i++){
		dfs(v[x][i]);
		f[x]=max(f[x],f[v[x][i]]+1);
	}
}
int main()
{
	cin>>n>>m;
	int x,y;
	memset(f,-1,sizeof(f));
	for(int i=1;i<=m;i++){
		cin>>x>>y;
		v[x].push_back(y);
	}
	for(int i=1;i<=n;i++){
		dfs(i);
	}
	int ans=-1;
	for(int i=1;i<=n;i++){
		ans=max(ans,f[i]);
	}
	cout<<ans;
	return 0;
}



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

int main(){
	ll n,k; cin >> n >> k;
	vl p(n);
	rep(i,n) cin >> p[i];
	set<ll> se;
	vb v(n-1,false);
	ll ans = 1;
	bool flag = false;
	rep(i,k){
		se.insert(p[i]);
		if(i==k-1 || p[i]<p[i+1]) v[i] = true;
	}
	rep(i,n-k){
		auto itr = se.end();
		itr--;
		if(p[i]!=*se.begin() || p[i+k]<*itr) ans++;
		se.erase(p[i]); se.insert(p[i+k]);
	}
	rep(i,n-1) if(p[i]<p[i+1]) v[i] = true;
	ll streak = 0;
	rep(i,n){
		if(v[i]) streak++;
		else streak = 0;
		if(streak > k-1) continue;
		if(streak == k-1) ans--, flag = true;
	}
	if(flag) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
using ll = long long;
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;};

const Int MAX = 202;
Int dp[5][MAX]={};
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n,m;
  cin>>n>>m;

  const Int MOD = 1e6;
  
  if(m==1){
    Int res=1;
    for(Int i=0;i<n;i++) res=res*2%MOD;
    cout<<res<<endl;
    return 0;
  }
  assert(m==2);
  
  auto add=[&](Int &a,Int b){a+=b;a%=MOD;};                             
  dp[2][0]=1;
  for(Int i=0;i<n;i++){
    add(dp[4][i+1],dp[0][i]);
    add(dp[0][i+1],dp[0][i]);

    add(dp[2][i+1],dp[1][i]);
    add(dp[1][i+1],dp[1][i]);

    add(dp[0][i+1],dp[2][i]);
    add(dp[2][i+1],dp[2][i]);
    add(dp[3][i+1],dp[2][i]);
    add(dp[4][i+1],dp[2][i]);

    add(dp[2][i+1],dp[3][i]);
    add(dp[3][i+1],dp[3][i]);
    add(dp[4][i+1],dp[3][i]);

    add(dp[1][i+1],dp[4][i]);
    add(dp[2][i+1],dp[4][i]);
    add(dp[3][i+1],dp[4][i]);
    add(dp[4][i+1],dp[4][i]);
  }
  
  Int ans=0;
  add(ans,dp[0][n]);
  add(ans,dp[2][n]);
  add(ans,dp[3][n]);
  add(ans,dp[4][n]);
  cout<<ans<<endl;
  return 0;
}



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

// ショートハンド
// #define ll intに変えればメモリ節約
#define ll long long
#define ld long double

const int MOD = 1e9 + 7;
#define INF 2e9

/* 
 * ループ系のマクロ
 * `REP(i, 10) { cout << i; }`のように、変数名,回数で動く
 */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/*
 * 正規表現
 */
#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
// `chmax(a, b)` aがbより小さければ、aをbに上書きする。chminは逆
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



ll a,b,c,d;
string s;
int main() {
    INIT();

    cin >> a >> b >> c >> d;
    
    ll result = -1e18;
    chmax(result, a * c);
    chmax(result, a * d);
    chmax(result, b * c);
    chmax(result, b * d);
    cout << result;
}

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

using namespace std;

char f[100010];
string t;

int main()
{
    int n,k,r,p,s,i,ans = 0;
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;
    for(i = 0; i < n; i ++)
    {
        if(i < k)
        {
            if(t[i] == 'r') ans += p;
            else if(t[i] == 's') ans += r;
            else if(t[i] == 'p') ans += s;
            f[i] = t[i];
        }
        else if(f[i-k] == t[i]) f[i] = 0;
        else
        {
            if(t[i] == 'r') ans += p;
            else if(t[i] == 's') ans += r;
            else if(t[i] == 'p') ans += s;
            f[i] = t[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
var a,b,c,i,j,n,s:longint;
begin
  readln(a,b,c,n);
  for i:=0 to a do
    for j:=0 to b do
      if ((n-i*500-j*100>=0) and (n-i*500-j*100<=c*50)) then
        inc(s);
  writeln(s);
end.

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;


int main()
{
    cin.sync_with_stdio(0);

    int K;
    string S;
    cin >> K >> S;
    int len = S.size();

    if (len <= K)
    {
        cout << S;
    }
    else
    {
        cout << S.substr(0, K) + "...";
    }
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k;
    cin>>n>>k;
    long long int count=0;
    long long int mod=1000000007;
    for(long long int i=k;i<=n+1;i++)
    {
        long long int min,max,curr;
        min=((i-1)*i)/2;
        max=(n*(n+1))/2-((n-i)*(n-i+1))/2;
        curr=max-min+1;
        count=(count%mod+curr%mod)%mod;
    }
    cout<<count%mod;
}

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

using namespace std;

#define K 600001
#define FOE(i, s, t) for (int i = s; i <= t; i++)

int ret, n;
int a[K];
#define LL long long

LL s[K];

int main(){
        scanf("%d", &n);
        FOE(i, 1, n) scanf("%d", &a[i]);
        sort(a + 1, a + n + 1);

        ret = n;
        FOE(i, 1, n){
                s[i] += a[i];
                s[i] += s[i - 1];
//              printf("s[%d] = %lld\n", i, s[i]);
                if (i != n && s[i] * 2 < (LL)a[i + 1]){
                        ret = n - i;
                }
        }
        printf("%d\n", ret);
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int N;
    cin >> N;
    vector<int> A(N + 2, 0);
    FOR (i, 1, N + 1) cin >> A[i];
    vector<int> cumL(N + 2, 0), cumR(N + 2, 0);
    REP (i, N + 1) {
        cumL[i + 1] = cumL[i] + abs(A[i] - A[i + 1]);
        cumR[i + 1] = cumR[i] + abs(A[N + 1 - i] - A[N - i]);
    }
    REP (i, N) cout << cumL[i] + cumR[N - i - 1] + abs(A[i] - A[i + 2]) << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        long X;
        try (Scanner sc = new Scanner(System.in)) {
            X = sc.nextLong();
        }
        long kouho = X;

        while(true) {
            boolean noDIv = true;
            for (int i = 2; i < kouho; i++) {
                if(kouho % i == 0) {
                    kouho++;
                    noDIv = false;
                    break;
                }            
            }
            if(noDIv) {
                //素数発見
                break;
            }
        }
        System.out.println(kouho);
    }
}


Measured memory_bytes: 21844
import java.io.*;
import java.util.*;

public class Main {

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

  private void solve() {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

      String[] ln = in.readLine().split(" ");
      final int A = atoi(ln[0]);
      final int B = atoi(ln[1]);
      final int Q = atoi(ln[2]);

      long[] s = new long[A+1];
      for (int i = 0; i < A; i++) {
        s[i] = atol(in.readLine());
      }
      s[A] = 1L << 40;

      long[] t = new long[B+1];
      for (int i = 0; i < B; i++) {
        t[i] = atol(in.readLine());
      }
      t[B] = 1L << 40;

      for (int q = 0; q < Q; q++) {
        long x = atol(in.readLine());
        long dist = 1L << 50;

        for (int c = 0; c < 2; c++) {
          long[] af = c == 0 ? s : t;
          long[] as = c == 0 ? t : s;

          for (int i = 0; i < 2; i++) {
            int posF = binarySearch(af, x) + i;
            long df = af[posF];

            for (int j = 0; j < 2; j++) {
              int posS = binarySearch(as, x) + j;
              long ds = as[posS];
              
              long d = Math.abs(x - df);
              d += Math.abs(df - ds);
              dist = Math.min(dist, d);
            }
          }
        }

        out.println(dist);
      }
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  int atoi(String s) { return Integer.parseInt(s); }
  long atol(String s) { return Long.parseLong(s); }

  private int binarySearch(long[] arr, long x) {
    int left = 0;
    int right = arr.length;

    while(right - left > 1) {
      int mid = (left + right) / 2;
      if(arr[mid] <= x)  left = mid;
      else right = mid;
    }
    return left;
  }
}

Measured memory_bytes: 46236
"""
https://atcoder.jp/contests/intro-heuristics/tasks/intro_heuristics_a
"""

import numpy as np
from numba import jit


@jit(nopython=True, parallel=False)  # type: ignore
def calc(D: np.ndarray, C: np.ndarray, S: np.ndarray) -> np.ndarray:
    play_contests = np.zeros(D)
    today_costs = np.zeros(26)
    for d in range(D):
        today_costs += C
        points = S[d] - C
        best_contest = np.argmax(points)
        play_contests[d] = best_contest
        today_costs[best_contest] = 0

    return np.asarray(play_contests + 1, dtype=np.int32)


def load_input_as_int_array() -> np.ndarray:
    return np.array([int(v) for v in input().split(" ")])


def main() -> None:
    D, = load_input_as_int_array()
    C = load_input_as_int_array()
    S = []
    for _ in range(D):
        S.append(load_input_as_int_array())

    result = calc(D, C, np.array(S))
    for v in result:
        print(v)
    # print("Yes" if result else "No")


main()


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << max(c - (a - b), 0) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,a) FOR(i,0,(int)(a)-1)
#define reset(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(), x.end()
#define uni(x) x.erase(unique(all(x)), x.end());
#define BUG(x) cout << #x << " = " << x << endl
#define BUGP(x) cout << #x << " = " << x._1 << ", " << x._2 << endl
#define PR(x,a,b) {cout << #x << " = "; FOR (_,a,b) cout << x[_] << ' '; cout << endl;}
#define CON(x) {cout << #x << " = "; for(auto _i:x) cout << _i << ' '; cout << endl;}
#define mod 1000000007
#define pi acos(-1)
#define eps 1e-6
#define pb push_back
#define sqr(x) (x) * (x)
#define _1 first
#define _2 second

long long k, lis[55], n;

int main() {
	ios::sync_with_stdio(false);
	cin >> k;
	n = 50;
	REP (i, n) lis[i] = n - 1 - k + (n + 1) * (k / n);
	REP (i, k % n) lis[i] += n + 1;
	cout << n << endl;
	REP (i, n) cout << lis[i] << ' ';
}	


Measured memory_bytes: 256
x,y = map(int,input().split())
left,right,up,down = 0,0,0,0
fiv1 = 0
fiv2 = 1
color = [1,2,3]
ans = 0
while not(left <= x <= right) or not(down <= y <=up):
  num = fiv1 + fiv2
  right += num
  fiv1 = fiv2
  fiv2 = num
  ans += 1
  
  if left <= x <= right and down <= y <= up:
    break
  num = fiv1 + fiv2
  up += num
  fiv1 = fiv2
  fiv2 = num
  ans += 1 

  if left <= x <= right and down <= y <= up:
    break
  num = fiv1 + fiv2
  left -= num
  fiv1 = fiv2
  fiv2 = num
  ans += 1

  if left <= x <= right and down <= y <= up:
    break  
  num = fiv1 + fiv2
  down -= num
  fiv1 = fiv2
  fiv2 = num
  ans += 1
print(color[ans%3])


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

#define fr first
#define sc second

using namespace std;
typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long u64;

const int NMAX = 1e5 + 3, KEK = 1453, CMAX = 'z' - 'a' + 1, INF = 2e9;
const double EPS = 1e-5;

vector<ii> g[NMAX];
vector<char> used(NMAX);
vector<int> ans(NMAX, -INF);
bool can = 1;

void dfs(int v) {
    used[v] = 1;
    if (ans[v] == -INF) {
        ans[v] = 0;
    }
    for (ii pp : g[v]) {
        int to = pp.fr, d = pp.sc;
        if (!used[to]) {
            ans[to] = ans[v] + d;
            dfs(to);
        } else if (ans[to] != ans[v] + d) {
            can = 0;
        }
    }
}

main() {
    #ifdef HOME
        freopen("input.txt", "r", stdin);
    #else
//        freopen("newphone.in", "r", stdin);
//        freopen("newphone.out", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int l, r, d;
        cin >> l >> r >> d, --l, --r;
        g[l].push_back({r, d});
        g[r].push_back({l, -d});
    }
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            dfs(i);
        }
    }
    if (can) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}


Measured memory_bytes: 11136
s=int(input())
n=s//3
mod=10**9+7

import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if s<3:
    print(0)
else:
    ans=0
    for i in range(1,n+1):
        ans+=comb(s-2*i-1,i-1)%mod
    ans%=mod
    print(ans)

Measured memory_bytes: 73676
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,c,d[30][30],a[500][500],cnt[3][30] = {},mi = INF;
	cin >> n >> c;
	for(int i = 0;i < c;i++){
		for(int j = 0;j < c;j++) cin >> d[i][j];
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			cin >> a[i][j]; a[i][j]--;
			cnt[(i + j) % 3][a[i][j]]++;
		}
	}
	for(int i = 0;i < c;i++){
		for(int j = 0;j < c;j++){
			for(int k = 0;k < c;k++){
				if(i != j && j != k && k != i){
					int sum = 0;
					for(int l = 0;l < c;l++) if(l != i) sum += cnt[0][l] * d[l][i];
					for(int l = 0;l < c;l++) if(l != j) sum += cnt[1][l] * d[l][j];
					for(int l = 0;l < c;l++) if(l != k) sum += cnt[2][l] * d[l][k];
					chmin(mi,sum);
				}
			}
		}
	}
	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>

int main(void) {
  int a, b, c, d, e, k;
  scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
  if (e-a > k) {
    printf(":(");
  } else {
    printf("Yay!");
  }
  return 0;
}

Measured memory_bytes: 128
import sys
input=lambda: sys.stdin.readline().rstrip()
r,c,k=map(int,input().split())
D=[[0]*c for _ in range(r)] 
for _ in range(k):
	ri,ci,v=map(int,input().split())
	ri-=1
	ci-=1
	D[ri][ci]=v

DP=[[[0]*(c+1) for _ in range(r+1)] for i in range(4)]
for i in range(r):
	for j in range(c):
		v=D[i][j]

		for ii in range(4):
			DP[0][i][j]=max(DP[0][i][j],DP[ii][i-1][j])
			if v!=0:
				DP[1][i][j]=max(DP[1][i][j],DP[ii][i-1][j]+v)

			DP[ii][i][j]=max(DP[ii][i][j],DP[ii][i][j-1])
			if v!=0 and ii!=0:
				DP[ii][i][j]=max(DP[ii][i][j],DP[ii-1][i][j-1]+v)
ans=0
for i in range(4):
	ans=max(ans,DP[i][r-1][c-1])
print(ans)



Measured memory_bytes: 423728
n, m = map(int, input().split())
A = [True] * (n+1)
for _ in range(m):
  a = int(input())
  A[a] = False

mod = 10**9 + 7
dp = [0] * (n+1)
dp[0] = 1
if A[1]:
  dp[1] = 1

for i in range(2, n+1):
  if A[i]:
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= mod

print(dp[n])

Measured memory_bytes: 13504
#include <bits/stdc++.h>
#include<iostream>
#include <math.h>//pow(x,y)=x^y 99999とかの場合+1するif文
#include <algorithm>//sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(init,i,n) for (int i=init; i <(n);i++)
#define ll long long
#define rev(s) reverse(s.begin(),s.end())
#define sor(v) sort(v.begin(),v.end())
#define PI 3.14159265358979323846264338327950L
//コード自動整形 Shift + Option + F @vscode
using namespace std;


/////main/////
int main() {
int x;
cin>>x;
if(x==1){
cout<<0<<endl;
}else{
cout<<1<<endl;
}
}
/////main/////

/////function/////

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const int MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> vec(n);
  for(int i=0;i<n;i++) {
    cin >> vec.at(i);
  }
  map<string, int> mp;
  
  for(int i=0;i<vec.size();i++) {
    mp[vec.at(i)] = 1;
  }
  
  cout << mp.size() << endl;
  
}

Measured memory_bytes: 25084
/*
 * FileName:     A
 * CreatedDate:  2020-04-26 20:59:52 +0900
 * LastModified: 2020-04-26 21:01:25 +0900
 */

#include <stdio.h>

int main(void){
    int s,w;
    scanf("%d %d",&s,&w);
    if(s<=w){
        printf("unsafe\n");
        return 0;
    }
    printf("safe\n");
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<string> vec(n,"");
  for(int i=0;i<n;i++) cin >> vec[i];
  sort(vec.begin(),vec.end());
  int count=0,max=0;
  for(int i=1;i<n;i++) {
    if(vec[i-1] == vec[i]) {
      count++;
    }
    else if(count > max) {
      max = count;
      count = 0;
    }else count=0;
  }
  if(count > max) max = count;
  count = 0;
  for(int i=1;i<n;i++){
    if(vec[i-1]==vec[i]) {
      count++; 
    }else if(count==max){
      cout << vec[i-1] << endl;
      count = 0;
    }else count=0;
    if (i==n-1 && count==max) cout << vec[i] << endl;
  }
  
  return 0;
}


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

int main(void)
{
	int i;
	char dat[1200];
	
	scanf("%[^\n]",&dat);
	
	for(i=0 ; i<strlen(dat) ; i++){
		if(dat[i]>=65 && dat[i]<=90){
			dat[i]+=32;
		}
		else if(dat[i]>=97 && dat[i]<=122){
			dat[i]-=32;
		}
		printf("%c",dat[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2040
#pragma comment (linker, "/STACK:256000000")
 
#define _USE_MATH_DEFINES
#define _CRT_NO_DEPRECEATE
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#include <memory.h>
#include <sstream>
#include <queue>
#include <cassert>
#include <ctime>
#include <complex>
#include <unordered_map>
#include <random>
 
using namespace std;
 
typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef pair<int64, int64> pll;
typedef pair<int64, int> pli;
typedef pair<pii, pii> piiii;
typedef pair<int64, int> pli;
typedef pair<int, char> pic; 

#define pb push_back
#define sq(x) ((x)*(x))
#define cube(x) (((x)*(x))*(x))
#define tmin(x,y,z) (min(min((x),(y)),(z)))
#define rand32() (((unsigned int)(rand()) << 16) | (unsigned int)(rand()))
#define rand64() (((unsigned int64)(rand32()) << 16) | (unsigned int64)(rand32()))
#define bit(mask, b) ((mask >> b) & 1)
#define biton(mask, bit) (mask | (((uint64)(1)) << bit))
#define bitoff(mask, bit) (mask & (~(((uint64)(1)) << bit)))
#define bitputon(mask, bit) (mask |= (((uint64)(1)) << bit))
#define bitputoff(mask, bit) (mask &= (~(((uint64)(1)) << bit)))
#define FAIL() (*((int*)(0)))++
#define INF ((int)(1e9) + 1337)
#define EPS (1e-9)
#define y1 yy1
#define y0 yy0
#define j0 jj0

const long double PI = acosl((long double)-1.0);
const int64 LINF = (int64)4e18;//((1ull << 63) - 1ull);
const int MOD = 1000000007;
int test;

const int MAXN = 505;

int n, m;
char field[MAXN][MAXN];
char red[MAXN][MAXN], blue[MAXN][MAXN];

void init()
{
	scanf ("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
	{
		scanf ("%s", &field[i][1]);
	}
}

void fill()
{
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			red[i][j] = blue[i][j] = '.';
		}
	}
	for (int i = 1; i <= n; i++)
	{
		red[i][1] = '#';
		blue[i][m] = '#';
		if (i & 1)
		{
			for (int j = 2; j < m; j++)
			{
				red[i][j] = '#';
			}
		}
		else
		{
			for (int j = 2; j < m; j++)
			{
				blue[i][j] = '#';
			}
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (field[i][j] == '#')
			{
				red[i][j] = blue[i][j] = '#';
			}
		}
	}
}

void print()
{
	for (int i = 1; i <= n; i++)
	{
		printf("%s\n", red[i] + 1);
	}
	printf("\n");
	for (int i = 1; i <= n; i++)
	{
		printf("%s\n", blue[i] + 1);
	}
}

void solve()
{
	init();
	fill();
	print();
}

void precalc()
{
	
}

void test_output()
{
	
}

int main()
{
	//srand(time(0)); test_output(100, 100, 100); 
    //ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _MY_DEBUG
    freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
#else
    //freopen(TASK ".in", "rt", stdin); freopen(TASK ".out", "wt", stdout);
#endif
	double start = clock();
	precalc();
	int tests = 1;
	//scanf ("%d", &tests);
	for (test = 1; test <= tests; test++)
	{
		solve();
	}
	//fprintf(stderr, "%.5lf\n", (clock() - start) / CLOCKS_PER_SEC);
    return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	VI a(n);
	rep(i, n) cin >>a[i];
	
	cout << (n-1 +k-2)/(k-1) <<"\n";
	return 0;
}


Measured memory_bytes: 640
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
// clang-format on

void solve(std::string S) {
  int ans = 0, s = S.length();
  rep(i, s / 2) {
    if (S[i] != S[s - 1 - i]) {
      ans += 1;
    }
  }
  cout << ans << endl;
}

int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


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

int n, m;
int s;

int main(){
	cin >> n;
 	m = n;
	while(m > 0){
		s += m % 10;
    	m /= 10;
    }
	cout << (n % s == 0 ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Unboxed.Mutable as MV

main = do
    (h:w:d:_)<-map read.words<$>getLine::IO[Int]
    as<-fmap concat $ replicateM h $ map read.words<$>getLine::IO[Int]
    q<-readLn::IO Int
    lrs<-replicateM q $ unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine::IO[[Int]]
    --
    lij <- MV.replicate (h*w) (0,0) :: IO (MV.IOVector (Int,Int))
    forM_ (zip [(i,j)|i<-[1..h],j<-[1..w]] as) $ \((i,j),a) ->
        MV.unsafeWrite lij (a-1) (i,j)
    --
    spp <- fmap V.fromList $ forM [0..d-1] $ \s -> do
        sp <- forM [s,(s+d)..(h*w)-d-1] $ \l -> do
            (si,sj) <- MV.unsafeRead lij l
            (ei,ej) <- MV.unsafeRead lij (l+d)
            return $ abs (si-ei) + abs(sj-ej)
        return $ UV.fromList $ scanl (+) 0 sp
    --
    putStr $ unlines $ map show $ map (solve spp d) lrs
--
solve spp d (l:r:_) = (p r1 r2) - (p l1 l2) 
    where
        l1 = (l+(d-1)) `mod` d
        l2 = (l-1) `div` d
        r1 = (r+(d-1)) `mod` d
        r2 = (r-1) `div` d
        p a b = (spp V.! a) UV.! b


Measured memory_bytes: 65020
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

int main(){
  int n;
  cin>>n;
  cout<<"ai1333"<<string(n/100,'3')<<endl;
}



Measured memory_bytes: 3140
x,y = map(int,input().split())
ans = 0
if x==1:
    ans+=300000
elif x == 2:
    ans+=200000
elif x == 3:
    ans+=100000
if y==1:
    ans+=300000
elif y==2:
    ans+=200000
elif y ==3:
    ans+=100000
if x==1 and y==1:
    ans+=400000
print(ans)

Measured memory_bytes: 3316
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int m = sc.nextInt();
  int[] f = new int[m+1];
  for(int i = 0;i < n;i++){
    int k = sc.nextInt();
    for(int j = 0;j < k;j++){
      int p = sc.nextInt();
      f[p]++;
    }
  }
  int ans = 0;
  for(int i = 0;i < m+1;i++){
    if(f[i] == n)ans++;
  }
  System.out.println(ans);
}}

Measured memory_bytes: 22448