akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)	A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V> 
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s,t;
    cin>>s>>t;
    ll cnt=0;
    rep(i,0,3)	if(s[i]==t[i])	cnt++;
    cout<<cnt<<endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    bool flag=1;
    for (int i=0;i<n-1;i++) {
        if (a[i]==a[i+1]) flag=0;
    }
    if (flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include<vector>
#include <map>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
main()
{
    int n;cin>>n;    cout<<n*n*n<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
d1 = []
d2 = []
cnt = 0

for i in range(n):
    a, b = map(int,input().split())
    d1.append(a)
    d2.append(b)

for i in range(n-2):
    if(d1[i] == d2[i] and d1[i+1] == d2[i+1] and d1[i+2] == d2[i+2]):
        cnt += 1

if(cnt > 0):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<typename A, size_t N, typename T>void Fill(A (&a)[N], const T &v){fill((T*)a,(T*)(a+N),v);}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD=1e9+7;
const int N=1e5;
int n, k, a[N], b[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  ll ans = 0;
  FOR(i, 0, n){
    cin >> a[i] >> b[i];
    if((k|a[i])==k) ans += b[i];
  }
  FORR(j, 29, 1){
    if((k&(1<<j))==0) continue;
    int l = (k>>(j+1))<<1;
    ll s = 0;
    FOR(i, 0, n) if((l|a[i]>>j)==l) s += b[i];
    maxs(ans, s);
  }
  cout << ans << endl;
}

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

    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        long long int n,k,a[102],p[102],dp[102][100006];
        cin>>n>>k;
        for(int i=1;i<=n;i++){
            cin>>a[i]>>p[i];
        }
        
        dp[0][0]=0;
        for(int i=1;i<=n;i++){
            for(int j=0;j<=k;j++){
                dp[i][j]=dp[i-1][j];
                if(j-a[i]>=0)dp[i][j]=max(dp[i][j],dp[i-1][j-a[i]]+p[i]);
            }
         }
         cout<<dp[n][k]<<'\n';
     
     
        return 0;
    }

Measured memory_bytes: 78592
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    const int M = 1000000;
    array<int, M+1> v{};
    v[0] = 1; v[1] = 1;
    for (int i = 2; i <= M; ++i) {
        if(v[i]) continue;
        for (int j = 2*i; j <= M; j += i) {
            v[j]++;
        }
    }
    int a, d, n;
    while(cin >> a >> d >> n, a|d|n){
        int cnt = 0, p = a;
        while(cnt < n){
            if(!v[p]) cnt++;
            if(cnt == n) break;
            p += d;
        }
        cout << p << "\n";
    }
    return 0;
}



Measured memory_bytes: 6964
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//inline int in() { int x; scanf("%d",&x); return x;}
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  string s; cin >> s;
  s.pb('R');
  int n = s.length(); // 2 <= n <= 10^5
  int rl = 0;
  int ans[2] = {0, 0};
  rep(i,n) {
    if (s[i] == 'R' && s[i+1] == 'L') {
      ans[0] = i - rl + 1;
      rl = i + 1;
    } else if (s[i] == 'L' && s[i+1] == 'R') {
      ans[1] = i - rl + 1;
      rl = i + 1;
      //cout << ans[0] << " " << ans[1] << " debug" << endl;
      rep(j,ans[0]-1) cout << 0 << " ";
      if ((ans[0]+ans[1]) % 2 == 0) {
        cout << (ans[0] + ans[1]) / 2 << " ";
        cout << (ans[0] + ans[1]) / 2 << " ";
      } else {
        if (ans[0] % 2 == 0) {
          cout << (ans[0] + ans[1] - 1) / 2 << " ";
          cout << (ans[0] + ans[1] + 1) / 2 << " ";
        } else {
          cout << (ans[0] + ans[1] + 1) / 2 << " ";
          cout << (ans[0] + ans[1] - 1) / 2 << " ";
        }          
      }
      rep(j,ans[1]-1) cout << 0 << " ";
    }
  }
  cout << endl;
  return 0;
}


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

main()
{
  int n;
  int c[501];
  int s[501];
  int f[501];
  int t[501];
  
  cin >> n;
  for(int i=0;i<n-1;i++)
    cin >> c[i] >> s[i] >> f[i];

  for(int i=0;i<n;i++){
    int ans=0;
    for(int j=i;j<n-1;j++){
      if(ans<=s[j])
        ans=s[j];
      else if(ans%f[j]!=0){
        int k;
        for(k=f[j];k<ans;k+=f[j]){int a;}
        ans+=k-ans;
      }
      ans+=c[j];
    }
    cout << ans << endl;
  }
  
  return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define PB push_back
#define PF push_front
#define MP make_pair
typedef long long int ll;
const ll mod = 1e9+7;
const ll INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}

int main(){
  int a,b;
  cin>>a>>b;
  
  cout<<max({a+b,a-b,a*b})<<endl;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
struct unionf{
	vector <int> data;
	unionf(int size):data(size,-1){}
	bool unions(int x,int y){
		x=root(x);y=root(y);
		if(x!=y){
			if(data[y]<data[x]){int d=x;x=y;y=d;}
			data[x]+=data[y];data[y]=x;
		}
		return x!=y;
	}
	bool finds(int x,int y){
		return root(x)==root(y);
	}
	int root(int x){
		return data[x]<0?x:data[x]=root(data[x]);
	}
	int find(int x){
		return -data[x];
	}
};
int main()
{
	int n,m,x,y,z;
	cin>>n>>m;
	unionf uni(n+10);
	rep(i,m){
		cin>>x>>y>>z;
		x--;y--;
		uni.unions(x,y);
	}
	set<int> s;
	rep(i,n){
		s.insert(uni.root(i));
	}
	cout<<s.size()<<endl;
}


Measured memory_bytes: 5376
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

int check[100];
int main()
{
    // input
    int N,K;
    int d[100];
    int A[100*100]; // A[i][j] = A + 100*i + j
    int ret = 0;
    scanf( "%d %d", &N, &K );
    for ( int i=0; i<K; i++ ) {
        scanf( " %d", d+i );
        for ( int j=0; j<d[i]; j++ ) {
            scanf( " %d", A + 100*i + j );
            check[ A[100*i+j]-1 ] = 1; 
        }
    }
    for ( int i=0; i<N; i++ ) {
        if ( check[i] == 0 ) ret++; 
    }

    // process

    // output
    printf( "%d\n", ret );

    return 0;
}


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

int main(){
  int n, k; cin >> n >> k;
  string s; cin >> s;
  vector<int> dir(n, 0);
  int len = 0;
  dir[0] = 1;
  for(int i=1; i<n; i++){
    if(s[i] == s[i-1]) dir[len]++;
    else {
      len++;
      dir[len]++;
    }
  }

  int ans = 0;
  for(int i=0; i<=len; i++){
    ans += dir[i] - 1;
  }
  if(len > 2*k) ans += 2*k;
  else ans = n-1;
  cout << ans << endl;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int const N = 1e4;
long long ans[2], n, p, temp, a[N], p_10 = 1; string s;
int main(){
    cin >> n >> p >> s;
    while(s.size()){
        temp = (p_10 * (s.back() - '0') + temp) % p, p_10 = (p_10 * 10) % p;
        ans[1] += (temp==0) + a[temp]++;
        ans[0] += (((s.back() - '0') % p) == 0) * s.size();
        s.pop_back();
    }    
    cout << ans[!(10%p == 0)] << endl;
    return 0;
}


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

static const int MAX = 200000;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  int n;
  cin >> n;
  for (int i = 2; i < 105000; i++) {
    bool ok = IsPrime(i);
    if (ok && n <= i) {
      cout << i << endl;
      break;
    }

  }
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int a, b; cin >> a >> b;
  if(a <= 8 && b <= 8) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}


Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

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

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

signed main(void) {
    int n;
    cin >> n;
    vi cnt(n+1,1);
    int ans = 1;
    loop(i,2,n+1){
        for(int j = 1; i*j <= n; j++)cnt[i*j]++;
        ans += i * cnt[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 81388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define maxn 100005
#define Mod 1000000007
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef set<int> si; 
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
#define __builtin_popcountll bitCountLL
#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
const int INF = 2e9;
const ll ML = 4e18;

void solve() {
    string s,t;
    cin >> s >> t;
    int n = s.size(), ans = 0;
    fori(i,0,n) {
        if(s[i] != t[i]) ans++;
    }
    cout << ans <<endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
//	freopen("D:\\data_in.txt", "r", stdin);
    solve();
    
    /*clock_t start,finish;
    start = clock();
   
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


Measured memory_bytes: 3780
#include<stdio.h>
#include<stdlib.h>
#define N 100
#define INF 1000000
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int a[N][N];

typedef struct node{
	int id;
	int cost;
}node;

void swap(node h[],int x,int y){
	node temp=h[x];
	h[x]=h[y];
	h[y]=temp;
	return;
}


void heapsort(node heap[],int num){

	for(int i=num-1;i>0;i--){
		if(i%2==0){
			if(heap[i].cost < heap[i/2-1].cost)swap(heap,i,i/2-1);
		}else {
			if(heap[i].cost < heap[i/2].cost)swap(heap,i,i/2);
		}
	}
	
	return;

}

int update_heap(node heap[],int num){
	int u=heap[0].id;
	swap(heap,0,num-1);
	num--;
	
	for(int i=0;i<num;i++){
		heap[i].cost=MIN(heap[i].cost,a[u][heap[i].id]);
	}
	
	return num;
}




int main(){
	int i,j,n;
	int num=0;/*heapの要素の個数*/
	int ans=0;
	node heap[N];
	
	
	scanf("%d",&n);
	
	
	/*隣接行列の読み込み*/
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			scanf("%d",&a[i][j]);
			if(a[i][j]==-1)a[i][j]=INF;
		}
	}
	
	/*0以外の頂点をinsert*/
	for(i=1;i<n;i++){
		heap[num].cost=a[0][i];
		heap[num++].id=i;
	}
	
	/*heapを昇順にソート*/
	heapsort(heap,num);
	
	while(num!=0){
		ans+=heap[0].cost;
		num=update_heap(heap,num);
		heapsort(heap,num);
	}
	
	printf("%d\n",ans);
	
	return 0;
	
}


Measured memory_bytes: 2712
object Main extends App {
  val Array(n, weight) = io.StdIn.readLine().split(' ').map(_.toInt)
  val items = Array.fill(n)(io.StdIn.readLine().split(' ').map(_.toInt))
  val dp: Array[Array[Long]] = Array.fill(n+1)(Array.fill(weight+1)(-1))
  dp(0)(0) = 0

  for (i <- 0 until n)
    for (w <- (0 to weight).filter(dp(i)(_) != -1)) {
      if (w+items(i)(0) <= weight) {
        val current = dp(i+1)(w+items(i)(0))
        val tmp = dp(i)(w) + items(i)(1)
        if (current < tmp) dp(i+1)(w+items(i)(0)) = tmp
      }
      if (dp(i+1)(w) < dp(i)(w)) dp(i+1)(w) = dp(i)(w)
    }
  println(dp(n).max)
}

Measured memory_bytes: 171328
from collections import defaultdict
n = int(input())
p = defaultdict(int)
for i in range(1,n+1):
  j = int(str(i)[0])
  k = int(str(i)[-1])
  p[(j,k)] += 1
ans = 0
for j in range(10):
  for k in range(10):
    ans += p[(j,k)]*p[(k,j)]
print(ans)

Measured memory_bytes: 9436
#include<stdio.h>
main()
{
        int i, n, b, f, r, v, house[4][3][10] = {0};
        scanf("%d", &n);
        for(i = 0; i < n; i++){
                scanf("%d %d %d %d", &b, &f, &r, &v);
                    house[b - 1][f - 1][r - 1] += v;
        }
        for(b = 1; b <= 4; b++){
                for(f = 1; f <= 3; f++){
                        for(r = 1; r <= 10; r++){
                                printf(" %d", house[b - 1][f - 1][r - 1]);
                        }
                        putchar('\n');
                }
                if(b != 4){
                        printf("####################\n");
                }
        }
}

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> rcnt(n);
    if(s[0]=='R') rcnt[0]=1;
    else rcnt[0]=0;
    rep(i,n-1){
        if(s[i+1]=='R')rcnt[i+1]=rcnt[i]+1;
        else rcnt[i+1]=rcnt[i];
    }
    int tot=rcnt[n-1];
    int ans=n;
    if(rcnt[n-1]==0){
        cout << 0 << endl;
        return 0;

    }
    rep(i,n){
        int x=rcnt[i];//r
        int y=i-x+1;//w
        int z=tot-x;//rの残り
        if(y>=z){
            cout << y << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 4448
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i = 0 ; i < n ; ++i)
#define rep1(i,n) for(int i = 1 ; i <= n ; ++i)
using namespace std;
typedef long long ll;
int n,wmax;
int w[110];
ll v[110];
ll dp[110][100010];
int main()
{
  cin >> n >> wmax;
  rep(i,n) cin >> w[i] >> v[i];

  rep(i,n+1){
    rep(j,wmax+1){
      dp[i][j] = 0;
    }
  }

  rep(i,n){
    rep(j,wmax+1){
      if(j-w[i]<0) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = max( dp[i][j] , dp[i][j-w[i]] + v[i] );
    }
  }
  
  ll res = 0;
  rep(j,wmax+1){
    res = max( res , dp[n][j]);
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 80128
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> players(N, 0);
  for (int i = 0; i < Q; ++i) {
    int A;
    cin >> A;
    ++players[A - 1];
  }
  for (auto& v : players)
    cout << (v > Q - K ? "Yes" : "No") << endl;
}


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

int main () {
  map<int,string> m;
  int a, b; cin >> a >> b;
  if (a == 1) a += 13;
  if (b == 1) b += 13;
  m[a] = "Alice";
  m[b] = "Bob";
  if (a == b) cout << "Draw" << endl;
  else cout << m[max(a,b)] << endl;
  return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  int n,m;
  cin>>n>>m;
  vector<vector<int>> vec(m,vector<int>(2));
  vector<vector<int>> ans(n,vector<int>(2));
  for(int i=0;i<m;i++){
    cin>>vec.at(i).at(0)>>vec.at(i).at(1);
  }
  if(m==0 && n>1){
    cout<<1;
    for(int i=0;i<n-1;i++){
      cout<<0;
    }
  }else if(m==0 && n==1){cout<<0<<endl;
  }else{
    for(int i=0;i<m;i++){
      if(vec.at(i).at(0)==1 && vec.at(i).at(1)==0 && n>1){
        cout<<-1<<endl;return 0;
      }
    }
    for(int i=0;i<m;i++){
      for(int j=i+1;j<m;j++){
        if(vec.at(i).at(0)==vec.at(j).at(0)){
          if(vec.at(i).at(1)!=vec.at(j).at(1)){
            cout<<-1<<endl;return 0;
          }
        }
      }
    }
    for(int i=0;i<n;i++){
      ans.at(i).at(0)=i;
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        if(vec.at(j).at(0)==i+1){ 
          ans.at(i).at(1)=vec.at(j).at(1);
          break;
        }else{
          if(i!=0){ans.at(i).at(1)=0;}
          else{ans.at(0).at(1)=1;}
        }
      }
    }
    for(int i=0;i<n;i++){
      cout<<ans.at(i).at(1);
    }
  }
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> PP;

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

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

	int h1,m1,s1,h2,m2,s2;
	REP(i,3) {
		cin>>h1>>m1>>s1>>h2>>m2>>s2;
		int a=h1*3600+m1*60+s1,b=h2*3600+m2*60+s2;
		int c=b-a;
		int s3=c%60;c/=60;
		int m3=c%60;c/=60;
		int h3=c;
		cout<<h3<<' '<<m3<<' '<<s3<<endl;
	}

	return 0;
}



Measured memory_bytes: 3220
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  cin.tie(0);
  int n;
  cin >> n;

  vector<int> as(n);

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

  int odd = 0;
  for (int i = 0; i < n; i++) {
    if (as[i] % 2 == 1)
      odd++;
  }

  if (n == 2 && odd == 2) {
    cout << "YES" << endl;
    return 0;
  }

  cout << (odd % 2 == 0 ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <string.h>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

#define DIST(a, b) (((a) - (b) + 26)%26)

int dht = DIST('h', 't');
int deh = DIST('e', 'h');
int dah = DIST('a', 'h');
int dta = DIST('t', 'a');
int dih = DIST('i', 'h');
int dsi = DIST('s', 'i');

int check(const char* word)
{
	if (DIST(word[1], word[0]) != dht)
		return -1;

	if (DIST(word[2], word[1]) == deh && 
		(word[3] == ' ' || word[3] == '\0' || word[3] == '.'))
	{
		return DIST(word[0], 't');
	}
	if (DIST(word[2], word[1]) == dah && 
		DIST(word[3], word[2]) == dta &&
		(word[4] == ' ' || word[4] == '\0' || word[4] == '.'))
	{
		return DIST(word[0], 't');
	}
	if (DIST(word[2], word[1]) == dih && 
		DIST(word[3], word[2]) == dsi && 
		(word[4] == ' ' || word[4] == '\0' || word[4] == '.'))
	{
		return DIST(word[0], 't');
	}
	return -1;
}

int main(int argc, char const *argv[])
{
	string s;
	while (getline(std::cin, s))
	{
		int len = s.length();
		int d = check(&s[0]);
		int i = 3;
		while (d == -1)
		{
			while(i < len && s[i] != ' ')
				i++;
			if (i == len) break;
			i++;
			d = check(&s[i]);
		}
		REP(j, len)
		{
			if (s[j] >= 'a' && s[j] <= 'z')
			{
				s[j] = (s[j] - 'a' - d + 26) % 26 + 'a';
			}
		}
		std::cout << s << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3128
N = int(input())
n = [int(i) for i in input().split()]
l = sum(n)
s=0
for i in range(N):
        s+=n[i]
        if s>=l/2:
                if abs(l/2-s) > s1:
                        s-=n[i]
                e = l-s
                break     
        s1=abs(l/2 - s)
print(abs(s-e))

Measured memory_bytes: 26220
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;


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


























int main(){
    string s, t;
    cin >> s >> t;
    ll n = s.size(), m = t.size();
    ll ans = INF;
    REP(i, n - m + 1){
        ll cnt = 0;
        REP(j, m){
            if(s[i + j] != t[j]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int K;
  cin>>K;
  vector<int> A= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  cout<<A.at(K-1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 55
using namespace std;
const int INF = 1e9;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef priority_queue<PP,vector<PP>,greater<PP> > PQ;
int n, fee[N], height[N],G[2][N][N];
int D[N][N][1<<10];

int Push(PQ &Q,int cost,int p1,int p2,int bit){
  if(D[p1][p2][bit] <= cost) return 0 ;
  D[p1][p2][bit] = cost;
  Q.push(PP(P(cost,p1),P(p2,bit)));
  return 1;
}

int dijkstra(){

  int idx[N];
  map<int,int> cnt;
  for(int i=0;i<n;i++) idx[i] = cnt[height[i]]++;

  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      for(int k=0;k<(1<<10);k++) D[i][j][k] = INF;
  PQ Q;
  Push(Q,0,0,0,1<<idx[0]);
  
  while(!Q.empty()){
    PP t = Q.top();Q.pop();
    int cost = t.first.first;
    int p1 = t.first.second;
    int p2 = t.second.first;
    int bit = t.second.second;
    if(D[p1][p2][bit] < cost) continue;
    if(p1 == n-1 && p2 == n-1) return cost;
    
    for(int to=0;to<n;to++){
      int ncost = cost + G[0][p1][to] + fee[to];
      int nbit = bit;
      if(height[p1] == height[to]) nbit |= 1<<idx[to];
      else nbit = 1<<idx[to];
      Push(Q,ncost,to,p2,nbit);
    }
    
    for(int to=0;to<n;to++){
      if(height[p1] < height[to]) continue;
      int ncost = cost + G[1][p2][to] + fee[to];
      if(height[p1] == height[to] && bit>>idx[to]&1) ncost -= fee[to];
      Push(Q,ncost,p1,to,bit);
    }
  }
  return -1;
}

signed main(){
  while(1){
  int m;
  cin>>n>>m;
  if(n == 0 && m == 0) return 0;
  memset(fee,0,sizeof(fee));
  memset(height,0,sizeof(height));
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++) G[0][i][j] = G[1][i][j] = INF;
  
  height[0] = 0;
  height[n-1] = 1000;
  for(int i=1;i<n-1;i++) cin>>fee[i]>>height[i];
  
  for(int i=0;i<m;i++){
    int a,b,c;
    cin>>a>>b>>c; a--, b--;
    if(height[a] <= height[b]) Min(G[0][a][b],c);
    if(height[a] >= height[b]) Min(G[1][b][a],c);
  }
  cout<<dijkstra()<<endl;
  }
  return 0;
}

Measured memory_bytes: 31352
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=100;
int n,dir,lim; //[lim,dir]
int dis[N+5],tot[N+5];
const char ANS[2][20]= {"Impossible","Possible"};
int main() {
	scanf("%d",&n);
	for(int i=0; i<n; i++) {
		scanf("%d",&dis[i]);
		tot[dis[i]]++;
	}
	sort(dis,dis+n);
	dir=dis[n-1];
	lim=(dir+1)/2;
	if(dis[0]<lim || dir+1>n) {
		printf("%s\n",ANS[0]);
		return 0;
	}
	for(int i=dir; i>=lim; i--) {
		if(i==lim) {
			if((dir%2==0 && tot[i]!=1) || (dir%2==1 && tot[i]!=2)) {
				printf("%s\n",ANS[0]);
				return 0;
			}
		} else if(tot[i]<2) {
			printf("%s\n",ANS[0]);
			return 0;
		}
	}
	printf("%s\n",ANS[1]);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second 
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  string s;
  cin >> s;
  int n = (int) s.size();
  int ans = 0;
  for(int i = 0; i < n / 2; ++i) {
    ans += s[i] != s[n - 1 - i];
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)



int main(void)
{

	int a, b, c, d;

	cin >> a >> b >>  c >> d;


	cout << max(-max(a, c) + min(b, d), 0) << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{ int a,b,x;
 while(~scanf("%d%d%d",&a,&b,&x))
 {
  if(a>x)
  printf("NO\n");
  if(a<=x)
  {if(a+b>=x)
  printf("YES\n");
  if(a+b<x)
  printf("NO\n");
  }
 }
    return 0;
}


Measured memory_bytes: 128
n = int(input())
li = list(map(int,input().split()))
a = li[0]
s = sum(li)
b = s - a
ans_li = [abs(a-b)]
#print(ans_li)

for i,l in enumerate(li):
    if i == 0:
        continue
    if i == n-1:
        continue
    a+=l
    b-=l
    ans_li.append(abs(a-b))
print(min(ans_li))

Measured memory_bytes: 86608
n = int(input())
a = list(map(int, input().split()))

a.sort()
s = set(a)
if a[0] != 0:
    if (len(s) > 3) or (len(s) == 1) or (len(s) == 2):
        print('No')
        exit()

    l = [a[0]]
    c = []
    count = 1
    for i in range(n - 1):
        if a[i + 1] != a[i]:
            l.append(a[i + 1])
            c.append(count)
            count = 1
        else:
            count += 1
    c.append(count)

    if n % 3 != 0:
        print('No')
        exit()

    c.sort()
    if c[0] != c[1] or c[1] != c[2]:
        print('No')
        exit()

    if (l[0] ^ l[1]) == l[2]:
        print('Yes')
        exit()
    print('No')
else:
    if len(s) == 1:
        print('Yes')
        exit()
    if len(s) > 3:
        print('No')
        exit()
    if len(s) == 3:
        print('No')
        exit()

    c = []
    count = 1
    for i in range(n - 1):
        if a[i + 1] != a[i]:
            c.append(count)
            count = 1
        else:
            count += 1
    c.append(count)

    if n % 3 != 0:
        print('No')
        exit()

    if c[0] * 2 == c[1]:
        print('Yes')
        exit()
    print('No')
    exit()


Measured memory_bytes: 14212
s = gets.chomp
n = gets.to_i

ans1 = eval(s)

a = s.split(/[+*]/).map(&:to_i)
op = s.chars.select {|c| c =~ /[+*]/ }
ans2 = a[0]
op.each_index do |i|
    if op[i] == '+'
        ans2 += a[i + 1]
    else
        ans2 *= a[i + 1]
    end
end

if [ans1, ans2] == [n, n]
    puts "U"
elsif ans1 == n
    puts "M"
elsif ans2 == n
    puts "L"
else
    puts "I"
end


Measured memory_bytes: 6876
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SZ(x) ((int)(x).size())
typedef long long ll;

using namespace std;

int main(){
  int X,A;
  cin >> X >> A;
  if(X<A) cout << 0 << endl;
  else cout << 10 << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt"adj[i], "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

int n , ok = 1;
ll a[maxn];
vector < int > adj[maxn];
ll dp[maxn];

ll dfs(int v , int par = 0){
    if(adj[v].size() == 1)
        return(a[v]);
    ll sum =0 ;
    for(auto u : adj[v])
        if(u!=par){
            ll x = dfs(u , v);
            if(x > a[v])
                ok = 0;
            sum += x;
        }
    if(sum < a[v] or sum > 2*a[v])
        ok = 0;
    if(par == 0 and sum!= 2 * a[v])
        ok = 0;
    return(2 * a[v] - sum);
}

int main(){
    migmig
    cin >> n;
    for(int i = 1 ; i <= n ; i ++)
        cin >> a[i];
    for(int i = 1 ; i < n ; i ++){
        int u , v;
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    if(n == 2){
        dokme(((a[1] == a[2]) ? "YES" : "NO" ));
    }
    for(int i = 1 ; i <= n ; i ++){
        if(adj[i].size() > 1){
            dfs(i);break;}
    }
    cout << ((ok) ? "YES" : "NO");
    return(0);
}

Measured memory_bytes: 84436
N = int(input())
ans = 2
n = N
A = [N]
while True:
    if n % 2 == 0:
        n //= 2
    else:
        n = 3 * n + 1
    if n in A:
        print(ans)
        exit()
    A.append(n)
    ans += 1

Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int N;
	cin >> N;
	int* x = new int[N];
	for (size_t i = 0; i < N; i++)
		cin >> x[i];

	int* ways = new int[N];
	
	for (size_t j = 0; j < N; j++)
		ways[j] = 0;
		
	ways[0] = 2;

	long long start = 0;
	for (size_t i = 2; i < N; i++)
	{
		if ((x[i - 1] + 1) / 2 < i - start)
			start++;
		ways[start]++;
	}

	for (size_t i = 1; i < N; i++)
		ways[i] += ways[i-1];

	long long result = ways[0];
	for (int j = 1; j < N; j++)
		result = (result * (ways[j] - j)) % 1000000007;

	cout << result;

	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

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

        char s = a.toCharArray()[0];

        String res = "";
        if (Character.isLowerCase(s)) {
            res = "a";
        } else {
            res = "A";
        }

        System.out.println(res);

    }
}


Measured memory_bytes: 35432
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int MOD=MOD2;



int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
            int k;
            cin>>k;
            string s;
            cin>>s;
            int len=s.length();
            if(len<=k)cout<<s<<endl;
            else
            {
                  cout<<s.substr(0,k)<<"..."<<endl;
            }
            
      } 
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

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

int main(){
  int64_t n,m,a,b,ch,h,k,d;
  d=0;
  k=0;
  h=0;
  ch=0;
  cin>>n>>m;
  vector<vector<int64_t>> data(n);
  for(int64_t i=0;i<m;i++){
    cin>>a>>b;  
    data.at(a-1).push_back(b-1);
    data.at(b-1).push_back(a-1);
  } 
  vector<int64_t> num(n);
  vector<int64_t> pas(n);
  vector<int64_t> hon;
  vector<int64_t> kari;
  vector<int64_t> hikaku={};
  hon.push_back(0);  
  while(ch!=0||hon!=hikaku){
    h=hon.size();
    for(int64_t i=0;i<h;i++){
      d=data.at(hon.at(i)).size();
      for(int64_t j=0;j<d;j++){
        if(num.at(data.at(hon.at(i)).at(j))==0&&data.at(hon.at(i)).at(j)!=0){
          num.at(data.at(hon.at(i)).at(j))=num.at(hon.at(i))+1;
          kari.push_back(data.at(hon.at(i)).at(j));
          pas.at(data.at(hon.at(i)).at(j))=hon.at(i);
        }
      }
    }
    ch=1;
    hon={};
    k=kari.size();
    for(int i=0;i<k;i++){
      hon.push_back(kari.at(i));
    }
    kari={};
    ch=0;
  }
  cout<<"Yes"<<endl;
  for(int64_t i=1;i<n;i++){
    cout<<pas.at(i)+1<<endl;  
  }
}

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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main() {

    long long int s, w;
    cin >> s >> w;

    if ( w >= s ) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }

    return 0;

}


Measured memory_bytes: 3636
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>


using namespace std;


int main()
{
  	string s;
	cin>>s;
    cout<<2018<<s.substr(4);
     system("pause");
    return 0;
}     

Measured memory_bytes: 504
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int l = s.nextInt();
		int array[] = new int[n];
		int sum = 0;
		for (int a = 0; a < array.length; a++) {
			array[a] = a + l;
			sum += a + l;
		}
		int min = 999, j = -1;
		for (int a = 0; a < array.length; a++) {
			if (min > array[a])j = a;
			min = Math.min(min, Math.abs(array[a]));
		}
		System.out.println(sum - array[j]);
	}
}


Measured memory_bytes: 23764
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

# A：時
# B：分
A, B, H, M = [int(x) for x in stdin.readline().rstrip().split()]


total_minute = H * 60 + M

tyosin = 6 * total_minute % 360
tanshin = 0.5 * total_minute % 360

kakudo = abs(tyosin - tanshin)

if kakudo > 180:
    kakudo = 360 - kakudo

C2 = A**2 + B**2 - 2*A*B*math.cos(math.radians(kakudo))

print(math.sqrt(C2))

Measured memory_bytes: 10784
def main():
  n=int(input())
  a=sorted(map(int,input().split()))
  maxa=a[-1]+1
  tf=[False]*maxa
  r=0
  n-=1
  for i in range(n):
    a_i=a[i]
    if tf[a_i] ==False:
      for j in range(a_i,maxa,a_i):
        tf[j]=True
      if a_i  <a[i+1]:
        #print(a_i)
        r+=1
  if tf[-1] ==False:
    r+=1
  print(r)
main()


Measured memory_bytes: 32248
n, m = map(int, input().split())
light = [0 for _ in range(m)]
for i in range(m):
  key = [int(x) for x in input().split()]
  light[i] = key[1:]

p = [int(x) for x in input().split()]

ans = 0
for i in range(2**n):
  switch = [0]*n
  for j in range(n):
    if (i >> j) & 1:
      switch[j] = 1
  for j in range(m):
    x = 0
    for k in light[j]:
      if switch[k-1]:
        x += 1
    if x % 2 == p[j]:
      pass
    else:
      break
    if j == m-1:
      ans += 1
      
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <list>

using namespace std;
using ll = long long;

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

    vector<int> w(N), v(N);

    for(int i = 0; i < N; ++i)
    {
        cin >> w[i];
        cin >> v[i];
    }

    vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));

    for(int i = 1; i <= N; ++i)
    {
        for(int j = 1; j <= W; ++j)
        {
            if(j - w[i - 1] < 0)
                dp[i][j] = dp[i - 1][j]; // Exclude item i as it does not fit in bag of size j
            else
                dp[i][j] = max(dp[i - 1][j],  // Exclude item i
                                dp[i - 1][j - w[i - 1]] + v[i - 1]); // consider item i and bag filled with i - 1 items of weight j - w[i - 1]
        }
    }

    cout << dp[N][W] << "\n";

    return 0;
}


Measured memory_bytes: 80256
#include <stdio.h>
int main(void){
	int n,m,c;
	int i,j;
	int a[21][21];
	scanf("%d%d%d",&n,&m,&c);
	for(i=0;i<n+1;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	int temp;
	int ans = 0;
	for(i=1;i<n+1;i++){
		temp = 0;
		for(j=0;j<m;j++){
			temp+= a[0][j]*(a[i][j]);
		}
		temp += c;
		if(temp>0){
			ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
    int a[200005];
    int cnt[200005]={0};
    set <int> st;
    vector <int> vec;
int main(void)
{
    int n,k;
    cin>>n>>k;

    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
        st.insert(a[i]);
    }
    if(st.size()<=k)
    {
        cout<<0<<endl;
        return 0;
    }
    sort(cnt,cnt+n+1,[](int& x,int& y){return x>y;});
    for(auto i:cnt)
    {
        if(i==0)
            break;
        vec.push_back(i);
    }//for(auto i:vec)cout<<i<<" ";cout<<endl;
    int ans=0;
    int c=0;
    for(auto i=vec.rbegin();i!=vec.rend();i++)
    {
        if(c==st.size()-k)
            break;
        ans+=*i;
        c++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 12284
import math
n,d = map(int,input().split())
#x=list( map(int,input().split())
xl=[]
for i in range(n):
    xl.append(list (map(int,input().split())))
#print(xl)
sum_a2=0
cnt=0
for i in range (n):
    for j in range (n):
        sum_a2=0
        if (i<j):
            for k in range(d):
                a=xl[i][k]-xl[j][k]
                a2=a*a
                sum_a2=sum_a2+a2
            ans=math.sqrt(sum_a2)
            #print(ans,'ans',ans.is_integer())
            if (ans.is_integer()):
                cnt=cnt+1
print(cnt)

#print(minans)



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;


int main(){
int a,b;cin>>a>>b;
if(a>b)swap(a,b);
if(b-1<a)cout<<b+a;
else cout<<b+(b-1);

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){
#ifdef DEBUG
	
#endif
	int N, A;
	scanf("%d", &N);
	scanf("%d", &A);

	printf("%d\n", N*N - A);
}

Measured memory_bytes: 128
Position = Struct.new(:x, :y)

loop do
  w, h = gets.split.map(&:to_i)
  break if (w + h).zero?
  field = Array.new(h + 1) {Array.new(w + 1, 0)}
  
  xs, ys = gets.split.map(&:to_i)
  xg, yg = gets.split.map(&:to_i)
  start = Position.new(xs, ys)
  
  gets.to_i.times do
    color, direction, x, y = gets.split.map(&:to_i)
    width, height = direction.zero? ? [4, 2] : [2, 4]
    height.times do |h1|
      width.times {|w1| field[y + h1][x + w1] = color}
    end
  end
  
  start_color = field[ys][xs]
  field[ys][xs] = 100
  stack = [start]
  result = "NG"
  
  while (po = stack.shift)
    if po.x == xg && po.y == yg
      result = "OK"
      break
    else
      [[1, 0], [0, -1], [-1, 0], [0, 1]].each do |dx, dy|
        next_x, next_y = po.x + dx, po.y + dy
        next if next_x <= 0 || next_x > w || next_y <= 0 || next_y > h
        if field[next_y][next_x] == start_color
          stack << Position.new(next_x, next_y)
          field[next_y][next_x] = 100
        end
      end
    end
  end
  
  puts result
end



Measured memory_bytes: 7288
#include<bits/stdc++.h>
#define mod 1000000009
#define ll long long
using namespace std;
int main()
{
    int a,b,c,k;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    if(a+b>=k)
        printf("%d\n",min(a,k));
    else
    {
        int tmp=k-(a+b);
        printf("%d\n",a-tmp);
    }
    return 0;
}


Measured memory_bytes: 3828