akhauriyash/Code-Regression huggingface dataset:
#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 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 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 pair<int,P> PP;

vector<PP> v;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main()
{
	int n,d[100005];
	cin >> n;
	rep(i,n) cin >>d[i];
	sort(d,d+n);
	int ans = d[n/2] - d[n/2-1];
	//cout << d[n/2] <<" " <<d[n/2-1] << endl;
	cout << ans << endl;
	
	return 0;
}


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

typedef long long ll;

const string rgb = "RGB";
const int Maxn = 4004;

int n;
char str[Maxn];
int my[Maxn];
int sum[Maxn][3];
ll res;

int main()
{
    scanf("%d", &n);
    scanf("%s", str + 1);
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 3; j++)
            sum[i][j] = sum[i - 1][j];
        my[i] = rgb.find(str[i]);
        sum[i][my[i]]++;
    }
    for (int i = 1; i <= n; i++)
        for (int j = i + 2; j <= n; j++) if (str[i] != str[j]) {
            int nd = 3 - my[i] - my[j];
            int add = sum[j - 1][nd] - sum[i][nd];
            if ((i + j) % 2 == 0) {
                int mid = (i + j) / 2;
                if (my[mid] == nd) add--;
            }
            res += add;
        }
    cout << res << endl;
    return 0;
}


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

int main() {
   int a, b, c;
   cin >> a >> b >> c;

   if (a + b >= c) {
       cout << "Yes" << endl;
   } else {
       cout << "No" << endl;
   }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
 
typedef long long lld;
typedef vector<lld> vlld;
typedef pair<lld,lld> pi;
typedef tuple<lld,lld,lld> tup;
const lld mod=(lld)1e9+7;
 
 
int main() {

	
  
    string s;
    cin>>s;
    int n=sz(s);
    lld sum=0;
    forn(i,n)
    {
  sum+=(s[i]-'0');
    }

    if(sum%9==0)
    	cout<<"Yes";
    else
    	cout<<"No";

  
  return 0;
}

Measured memory_bytes: 3748
#include <cstdio>

using namespace std;

// 0A 1X 2Y 3Z 4W 5B 6

typedef struct {
	int naw;
	int next_1;
	int next_0;
}MAP;

int main()
{
	char road[150];
	MAP ma[6];
	
	ma[0].naw = 0;
	ma[0].next_1 = 2;
	ma[0].next_0 = 1;
	
	ma[1].naw = 1;
	ma[1].next_1 = 3;
	ma[1].next_0 = 6;
	
	ma[2].naw = 2;
	ma[2].next_1 = 6;
	ma[2].next_0 = 1;
	
	ma[3].naw = 3;
	ma[3].next_1 = 5;
	ma[3].next_0 = 4;
	
	ma[4].naw = 4;
	ma[4].next_1 = 2;
	ma[4].next_0 = 5;
	
	ma[5].naw = 5;
	ma[5].next_1 = 1;
	ma[5].next_0 = 2;
		
	while (scanf("%s", road), road[0] != '#'){
		int naw = 0;
		for (int i = 0;road[i] != '\0'; i++){
			if (road[i] == '0'){
				naw = ma[naw].next_0;
			}
			else{
				naw = ma[naw].next_1;
			}
			if(naw == 6) break;
		}
		
		if (naw == 5){
			puts("Yes");
		}
		else {
			puts("No");
		}
	}
}

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

using namespace std;
int n,m,k,i,j,x,y,a[200005],st=1,dr,mij,sol;
bool verif(int x)
{
    int nr=0;
    for(i=1;i<=n;i++)
        if(a[i]>x)
            nr+=a[i]/x+(a[i]%x!=0)-1;
    return nr<=k;

}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>k;
    for(i=1;i<=n;i++)
        {
            cin>>a[i];
            dr=max(dr,a[i]);
        }
    while(st<=dr)
    {
        mij=(st+dr)>>1;
        if(verif(mij)){
            sol=mij;
            dr=mij-1;
        }
        else st=mij+1;
    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 4372
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vll a(n);
    REP(i,n){
        cin >> a[i];
    } 
    ll ans = 0;
    vll xbi(45,0);
    REP(i,42){
        REP(j,n){
            xbi[i+1] += a[j]%2;
            a[j] >>= 1;
        }
    }
    bool f = false;
    for(ll i=42;i>=1;--i){
        if(xbi[i]>n/2){
            ans+=xbi[i]*(1LL<<(i-1));
            if((k>>(i-1))%2==1){
                f=true;
            }
        }else{
            if((k>>(i-1))%2==1||f){
                ans+=(n-xbi[i])*(1LL<<(i-1));
            }else{
                ans+=xbi[i]*(1LL<<(i-1));
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int v, e;
  cin >> v >> e;
  vvt<int> edge(v);
  vt<int> in(v, 0);
  rep(i, 0, e) {
    int s, t;
    cin >> s >> t;
    edge[s].push_back(t);
    in[t]++;
  }

  queue<int> que;
  rep(i, 0, v) {
    if(in[i] == 0) que.push(i);
  }

  vt<int> ans;
  while(!que.empty()) {
    int p = que.front();
    que.pop();
    ans.push_back(p);

    for(auto &nxt : edge[p]) {
      in[nxt]--;
      if(in[nxt] == 0) que.push(nxt);
    }
  }

  rep(i, 0, v) cout << ans[i] << endl;
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  string s,t;cin>>s>>t;
  for(int i=0;i<n;i++){
    string ss=s.substr(i);
    string tt=t.substr(0,n-i);
    if(ss==tt){
      cout<<n+i<<endl;
      return 0;
    }
  }
  cout<<2*n<<endl;
}




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

double manhattan(int x[],int y[],int n){
  int i,z;
  double D=0;
  for(i=0;i<n;i++){
    z = x[i] - y[i];
    if(z<0) z *= -1;
    D += z;
  }
  return D;
}

double euclid(int x[],int y[],int n){
  int i,z;
  double D=0;
  for(i=0;i<n;i++){
    z = x[i] - y[i];
    if(z<0) z *= -1;
    D += pow(z,2);
  }
  return sqrt(D);
}

double chebyshev(int x[],int y[],int n){
  int i,z,D=0;
  double max=0;
  for(i=0;i<n;i++){
    z = x[i] -y[i];
    if(z<0) z *= -1;
    if(z>max) max = z;
  }
  return max;
}

double p3(int x[],int y[],int n){
  int i,z;
  double D=0;
  for(i=0;i<n;i++){
    z = x[i] - y[i];
    if(z<0) z *= -1;
    D += pow(z,3);
  }
  return pow(D,1.0/3.0);
}

  


int main(void){
  int n,i;
  int x[100]={},y[100]={};
  double D[4]={};
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
  }
  for(i=0;i<n;i++){
    scanf("%d",&y[i]);
  }
  printf("%.6f\n%.6f\n%.6f\n%.6f\n",manhattan(x,y,n),euclid(x,y,n),p3(x,y,n),chebyshev(x,y,n));
  return 0;
}
		   

Measured memory_bytes: 1968
A,B,C,X = (int(input()) for X in range(0,4))
Count = 0
for TA in range(0,A+1):
    for TB in range(0,B+1):
        for TC in range(0,C+1):
            if 500*TA+100*TB+50*TC==X:
                Count += 1
print(Count)

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             998244353
#define endl            "\n"
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
int max(int a, int b) {if (a > b) return a; else return b;}
int min(int a, int b) {if (a < b) return a; else return b;}
// #DEBUG
void __print(int x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
// ###################################################################

void fast()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif
}
vector<int> stones;
int ans1 = INT_MAX;
int ans2 = INT_MAX;
int n;
int dp[100005];
int solve(int start) {
  if (start == n - 2) {
    return abs(stones[n - 1] - stones[n - 2]);
  }
  if (start == n - 1) {
    return 0;
  }
  if (dp[start] != -1) {
    return dp[start];
  }
  else {
    dp[start + 1] = solve(start + 1);
    dp[start + 2] = solve(start + 2);
    ans1 = abs(stones[start] - stones[start + 1]) + solve(start + 1);
    ans2 = abs(stones[start] - stones[start + 2]) + solve(start + 2);
    dp[start] = min(ans1, ans2);
    return dp[start];

  }
}
int32_t main()
{
  fast();
  cin >> n;
  memset(dp, -1, sizeof dp);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    stones.push_back(a);
  }
  cout << solve(0);
}

Measured memory_bytes: 6644
#include <iostream>
#include <string>
#include <queue>
#include <cmath>

#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{

    int n, res;
    string str;
    vector<string> s;
    
    res = 1;
    
    cin >> n;
    
    for(int i = 0; i < n; i++)
    {
        cin >> str;
        s.push_back(str);
    }
    
    sort(s.begin(), s.end());
    
    for(int i = 0; i < n - 1; i++)
    {
        if(s.at(i) != s.at(i + 1))
        {
            res++;
        }
    }
    
    cout << res << endl;
}

Measured memory_bytes: 11600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

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

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    string a;
    cin >> a;
    int b = a.size();
    vector<int> z(b+1);
    int p = 0;
    for (int i = b-1; i > -1; i--) {
        p += (a.at(i)-48)*modpow(10, b - i - 1, 2019);
        p %= 2019;
        z.at(i) = p;
    }
    sort(z.begin(), z.end());
    int ans = 0;
    int r = 0;
    for(int i = 0; i < b; i++) {
        if (z.at(i) == z.at(i + 1))r++;
        else {
            ans += r * (r + 1) / 2;
            r = 0;
        }
    }
        ans += r*(r + 1)/2;
        cout << ans << endl;
}

Measured memory_bytes: 4388
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}*/
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
map<int,int>mp;
multiset<string> st;
multiset<string> :: iterator it;

deque <char> q ;
int vis [1000];
int main()
{
    fast ;

    ll a ,b;
char op;
cin >> a >> op >> b;
if(op=='+')
{
 cout << a+b<<endl;
}
else
{
   cout << a-b<<endl;
}
}






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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  vector<ll>a(n);
  for(i=0;i<n;i++)cin>>a[i];
  cout<<(n-1+k-2)/(k-1)<<endl;
  return 0;
}

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

int n,E,Q;
int cap[505][505];

bool used[555];
vector<int>G[505];

void add_edge(int from,int to){
    G[from].push_back(to);
    G[to].push_back(from);
    cap[from][to]=cap[to][from]=1;
}

int dfs(int v,int t,int f){
    if(v==t)return f;
    used[v]=1;
    for(int i=0;i<G[v].size();i++){
        int e=G[v][i];
        if(!(!used[e]&&cap[v][e]>0))continue;
        int d=dfs(e,t,min(f,cap[v][e]));
        if(d){
            cap[v][e]-=d;
            cap[e][v]+=d;
            return d;
        }
    }
    return 0;
}

int flow(int s,int t,int lim){
    int fl=0;
    for(;;){
        memset(used,0,sizeof(used));
        int f=dfs(s,t,lim);
        if(!f)return fl;
        fl+=f;
        lim-=f;
    }
}

int main(){
    cin>>n>>E>>Q;
    r(i,E){
        int s,t;
        cin>>s>>t;s--;t--;
        add_edge(s,t);
    }
    int ANS=flow(0,n-1,1e9);
    r(i,Q){
        int m,s,t;
        cin>>m>>s>>t;s--;t--;
        if(m==1){
            add_edge(s,t);
            ANS+=flow(0,n-1,1);
        }
        else{
            if(cap[t][s]==2)swap(s,t);
            if(cap[s][t]==2){
                int x=flow(t,s,1);
                if(!x){
                    flow(n-1,0,1);
                    flow(t,s,1);
                    ANS--;
                }
            }
            cap[s][t]=cap[t][s]=0;
            G[s].erase(find(G[s].begin(),G[s].end(),t));
            G[t].erase(find(G[t].begin(),G[t].end(),s));
        }
        cout<<ANS<<endl;
    }
}


Measured memory_bytes: 4288
from sys import stdin

def fun():
    n = (int(i) for i in input().split())

    l = [int(x) for x in stdin.readline().rstrip().split()]

    l = list(set(l))
    l.sort()

    while 1 < len(l):
        k = len(l)
        for i in range(1, k):
            if l[k-i]%l[0] == 0:
                l.pop(k-i)
            elif l[k-i] - l[k-i-1] == 1:
                print(1)
                return
            else:
                l[k-i] = l[k-i]%l[0]
        #l = [e for e in l if e != 0]
        l = list(set(l))
        l.sort()

        if l[0]==1:
            print(1)
            return

    print(l[0])
    return

if __name__ == '__main__':
    fun()


Measured memory_bytes: 14480
import math
from collections import deque

class MaxFlow:
    class Edge:
        def __init__(self,to,cap,rev):
            self.to = to
            self.cap = cap
            self.rev = rev

    def __init__(self,n,inf = 10**9+7):
        self.n = n
        self.inf = inf
        self.level = [-1]*n
        self.iter = [0]*n
        self.e = [[] for _ in range(n)]

    def add_edge(self, from_, to, cap):
        self.e[from_].append(self.Edge(to, cap, len(self.e[to])))
        self.e[to].append(self.Edge(from_, 0, len(self.e[from_])-1))

    def bfs(self, start):
        self.level = [-1]*self.n
        dq = deque()
        self.level[start] = 0
        dq.append(start)
        while dq:
            cur_vertex = dq.popleft()
            for edge in self.e[cur_vertex]:
                if edge.cap > 0 > self.level[edge.to]:
                    self.level[edge.to] = self.level[cur_vertex] + 1
                    dq.append(edge.to)

    def dfs(self, cur_vertex, end_vertex, flow):
        if cur_vertex == end_vertex:return flow
        while self.iter[cur_vertex] < len(self.e[cur_vertex]):
            edge = self.e[cur_vertex][self.iter[cur_vertex]]
            if edge.cap > 0 and self.level[cur_vertex] < self.level[edge.to]:
                flowed = self.dfs(edge.to, end_vertex, min(flow, edge.cap))
                if flowed > 0:
                    edge.cap -= flowed
                    self.e[edge.to][edge.rev].cap += flowed
                    return flowed
            self.iter[cur_vertex] += 1
        return 0

    def compute(self, source, sink):
        flow = 0
        while True:
            self.bfs(source)
            if self.level[sink] < 0:return flow
            self.iter = [0]*self.n
            while True:
                f = self.dfs(source, sink, self.inf)
                if f == 0:break
                flow += f

def main():
    while True:
        n,m = map(int,input().split())
        if n==0:break
        a = []
        while True:
            c = list(map(int,input().split()))
            a.extend(c)
            if len(a)>=n:break
        b = []
        while True:
            c = list(map(int,input().split()))
            b.extend(c)
            if len(b)>=m:break
        MF = MaxFlow(n+m+2)
        s = n+m
        t = n+m+1
        for i in range(n):
            for j in range(m):
                if math.gcd(a[i],b[j])!=1:
                    MF.add_edge(i,j+n,1)
        for i in range(n):
            MF.add_edge(s,i,1)
        for i in range(m):
            MF.add_edge(i+n,t,1)
        print(MF.compute(s,t))

if __name__ == '__main__':
    main()




Measured memory_bytes: 52240
var abc=[];
for(var i=0;i<=1111;i++)abc[i]=Math.pow(i,3);
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var z=arr.shift()-0;
   if(z==0)break;
   var ans=Infinity;
   for(var i=z-1;i>0;i--){
      for(var j=i;j>0;j--){
         var x=abc[z]-abc[i]-abc[j];
         if(x>0 && ans>x)ans=x;
      }
   }
   console.log(ans);
}

Measured memory_bytes: 16012
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M);
    int ans=N;

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

    cout << (ans<0? -1: ans) << endl;    
} 




Measured memory_bytes: 3636
# 2019/08/07

a,b,c,d,e,f=map(int,input().split())

max_a=f//100*a
max_b=f//100*b
min_ab=min(a,b)*100
max_c=(f-min_ab)//c
max_d=(f-min_ab)//d


def solve():
    cnt=0   
    ans=0   
    for i in range(max_a):
        if i*a>f:break
        for j in range(max_b):
            if i==j==0:continue
            if (i*a+j*b)*100>f:break

            for k in range(max_c):
                if (i*a+j*b)*100+k*c>f:break
                for l in range(max_d):
                    if k==l==0:continue
                    if (i*a+j*b)*100+k*c+l*d>f:break
                    w=(i*a+j*b)*100
                    s=k*c+l*d
                    D=s/w
                    if D>e/100:break
                    if cnt<D:
                        ans=(w+s,s)
                        cnt=D
                    if D==e/100:
                        return ans
    return ans
ans=solve()
if ans==0:
    print(min(a,b)*100,0)
else:print(*ans)

Measured memory_bytes: 3064
S = list(input())

ans = S == list(reversed(S))
ans &= S[:(len(S)-1)//2] == list(reversed(S[:(len(S)-1)//2])) 
ans &= S[((len(S)+3)//2)-1:] == list(reversed(S[((len(S)+3)//2)-1:])) 

print('Yes' if ans else 'No')


Measured memory_bytes: 3060
#include <iostream>

int main() {
    int a, b, c;
    int number_of_devisor = 0;
    std::cin >> a >> b >> c;
    for (int i = a; i <= b; i++) {
        if (c % i == 0) {
            number_of_devisor++;
        }
    }
    std::cout << number_of_devisor << '\n';
    return 0;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll MOD = (ll)pow(10, 9) + 7;

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

  if((N - M >= 2) || (M - N >= 2)){
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  ll mini = min(M, N);
  rep2(i, 1, mini + 1){
    ans *= i;
    ans %= MOD;
  }

  if(M == N){
    ans *= ans;
    ans %= MOD;
    ans *= 2;
    ans %= MOD;
  } else{
    ans *= ans;
    ans %= MOD;
    ans *= max(M, N);
    ans %= MOD;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
vector<ll> get(ll n)
{
  vector<ll> v ;
  for(ll i = 1; i * i <= n ;i ++)
   {
     if(n % i == 0)
      {
        v.push_back(i) ;
        if(i * i != n) v.push_back(n / i) ;
      }
   }
   return v ;
}
int main()
{
  ll n ;
  cin >> n ;
  auto v = get(n - 1) ;
  ll ans = v.size() - 1 ;
  v = get(n) ;
  for(ll q : v)
   {
     if(q == 1) continue ;
     ll z = n ;
     while(z % q == 0) z /= q ;
     if(z % q == 1) ans ++ ;
   }
   cout << ans << endl ;
  return 0 ;
}


Measured memory_bytes: 384
// ~maqsat~

// #pragma GCC target ("avx2")
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")

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

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)
#define ever ;;

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 3e5 + 345;
const ll MOD = 998244353;
const ll INF = 1e15 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

#define int ll

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


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

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define pull pair<ull, ull>
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		int k;
		cin >> k;
		
		int a, b;
		cin >> a >> b;
		
		bool f=0;
		for(int i=a ; i<=b ; ++i){
			if(i%k == 0){
				f=1;
				break;
			}
		}
		
		if(f)cout << "OK";
		else cout << "NG";
	}
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
using  namespace std;
struct road
{
	int t;
	int c;
}r[105];
int main()
{
	int n,t;
	int mmin=100000;
	scanf("%d%d",&n,&t);
	while(n--)
	{
		int a,b;
		int aa,bb;
		scanf("%d%d",&a,&b);
		if(b<=t&&a<mmin)
		{
			bb=b;
			mmin=a;
		}
	}
	if(mmin==100000)
	{
		printf("TLE\n");
	}
	else 
	{
		printf("%d\n",mmin);
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(void)
{
    char r[5], a[5];
    while (1){
        scanf("%s %s", r, a);
        if (r[1] == '\0' && a[1] == '\0') break;
        int hit = 0, blow = 0;
        for (int i = 0; i < 4; i++){
            if (r[i] == a[i]) hit++;
        }
        for (int i = 0; i < 4; i++){
            for (int j = 0; j < 4; j++){
                if (r[i] == a[j]) blow++;
            }
        }
        printf("%d %d\n", hit, blow - hit);
    }
    
    return (0);
}

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

int main()
{
  string s;
  while (cin >> s) {
    int flag = 0;
    vector<string> g;
    vector<vector<string> > t;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == 'e') {
	i += 2;
	if (flag == 1) {
	  t.push_back(g);
	  g.clear();
	}
	flag = 1;
	g.push_back("egg");
      } else {
	i += 6;
	if (flag == 2) {
	  t.push_back(g);
	  g.clear();
	}
	flag = 2;
	g.push_back("chicken");
      }
    }

    if (!g.empty())
      t.push_back(g);

    int maxIndex = 0;
    for (int i = 1; i < t.size(); ++i) {
      if (t[i].size() > t[maxIndex].size())
	maxIndex = i;
    }

    cout << t[maxIndex].back() << endl;
  }
  return 0;
}

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

using namespace std;

struct simplehash {
  int len;
  long long base, mod;
  vector<int> P, H, R;

  simplehash() {}

  simplehash(string str, long long b, long long m) {
    base = b, mod = m, len = str.size();
    P.resize(len + 3, 1), H.resize(len + 3, 0), R.resize(len + 3, 0);
    for (int i = 1; i <= len; i++) {
      P[i] = (P[i - 1] * base) % mod;
    }
    for (int i = 1; i <= len; i++) {
      H[i] = (H[i - 1] * base + str[i - 1] + 1007) % mod;
    }
    for (int i = len; i >= 1; i--) {
      R[i] = (R[i + 1] * base + str[i - 1] + 1007) % mod;
    }
  }

  inline int range_hash(int l, int r) {
    int hashval = H[r + 1] - ((long long)P[r - l + 1] * H[l] % mod);
    return (hashval < 0 ? hashval + mod : hashval);
  }

  inline int reverse_hash(int l, int r) {
    int hashval = R[l + 1] - ((long long)P[r - l + 1] * R[r + 2] % mod);
    return (hashval < 0 ? hashval + mod : hashval);
  }
};

struct stringhash {
  simplehash sh1, sh2;

  stringhash() {}

  stringhash(string str) {
    sh1 = simplehash(str, 1949313259, 2091573227);
    sh2 = simplehash(str, 1997293877, 2117566807);
  }

  inline long long range_hash(int l, int r) {
    return ((long long)sh1.range_hash(l, r) << 32) ^ sh2.range_hash(l, r);
  }

  inline long long reverse_hash(int l, int r) {
    return ((long long)sh1.reverse_hash(l, r) << 32) ^ sh2.reverse_hash(l, r);
  }
};

string s;
stringhash yo;
int n, mob, ans;
unordered_map<long long, int> en;

bool check(int k) {
  en.clear();
  for (int i = 0; i + k - 1 < s.size(); i++) {
    long long x = yo.range_hash(i, i + k - 1);
    if (en[x]) {
      if (i > en[x]) return true;
    } else {
      en[x] = i + k - 1;
    }
  }
  return false;
}


int main() {
  cin >> n >> s;
  yo = stringhash(s);
  int L = 0, R = n, ans = 0;
  map<char, int> cnt;
  for (auto i : s) {
    cnt[i]++;
    if (cnt[i] > 1) {
      ans = 1;
      break;
    }
  }
  while (L <= R) {
    int M = (R + L) >> 1;
    if (check(M)) {
      ans = M;
      L = M + 1;
    } else {
      R = M - 1;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(){
	char a[7][4]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
	char s[3];
	int i;
	scanf("%s",s);
	for(i=0;i<7;i++)
	if(strcmp(a[i],s)==0)
	break;
	printf("%d\n",6-i+1);
	return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int a[N];
int n;
int l;

int32_t main()
{
	IOS;
	cin >> n;
	cin >> l;
	int ans=0;
	rep(i,1,n)
	{
		ans += l + i -1;
	}
	int best = INT_MAX;
	int ans2;
	rep(i,1,n)
	{
		int f= ans - (l+i-1);
		int diff = abs(f-ans);
		if(diff<best)
		{
			ans2=f;
			best = diff;
		}
	}
	cout << ans2 << endl;
}


Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//233
	int n;
	cin>>n;
	vi arr(n);
	int sum = 0;
	for(int &i:arr)cin>>i,sum+=i;
	int mi = INT_MAX;
	int lsum = 0;
	REP(i,0,n-1) {
		lsum+=arr[i];
		sum-=arr[i];
		mi=min(mi,abs(sum-lsum));
	}
	cout<<mi;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3648
N, X, Y = map(int, input().split())
dist = [0]*N
for i in range(1, N):
    for j in range(i+1,N+1):
        a = min(j-i, abs(i-X)+abs(Y-j)+1)
        dist[a] += 1
for i in range(1, N):
    print(dist[i])

Measured memory_bytes: 3444
n = int(input())
prev_dst = 0
prev_time = 0
for _ in range(n):
    t, x, y = map(int, input().split())
    total = x + y
    if t % 2 != total % 2 or (t - prev_time) < abs(total - prev_dst):
        print('No')
        exit()
    prev_time = t
    prev_dst = total
print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;

/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 * pair<型, 型> 変数名
 * map<型, 型> 変数名  // 連想配列
 * priority_queue<型> 変数名  // 最大値から出てくるヒープ
*/
int main()
{
    int N;
    cin >> N;
    vector<int> P(N), Q(N), R(N);
    REP(i, N) {
        cin >> P.at(i);
    }
    REP(i, N) {
        cin >> Q.at(i);
    }
    REP(i, N) {
        R.at(i) = i + 1;
    }
    int a, b, cnt = 0;
    do
    {
        cnt++;
        if (P == R)
        {
            a = cnt;
        }
        if (Q == R) {
            b = cnt;
        }
    } while (next_permutation(ALL(R)));
    cout << abs(a - b) << endl;
    return 0;
}

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

ll d[100005];
int main(){
    cin>>n>>k;
    priority_queue<ll> v[n];
    for(int i=0;i<n;i++){
        int t;
        ll d;
        cin>>t>>d;
        v[t-1].push(d);
    }
    
    priority_queue<ll> best,remain;
    for(int i=0;i<n;i++){
        if(!v[i].empty()){
            best.push(v[i].top());
            v[i].pop();
            while(!v[i].empty()){
                remain.push(v[i].top());
                v[i].pop();
            }
        }
    }
    vector<ll> bestsum={0};
    while(!best.empty()){
        bestsum.push_back(best.top()+bestsum.back());
        best.pop();
    }
    
    vector<ll> remainsum={0};
    while(!remain.empty()){
        remainsum.push_back(remain.top()+remainsum.back());
        remain.pop();
    }
    ll ans=0;
    for(ll i=1;i<=k;i++){
        if (i >= bestsum.size()) break;
        
        // 種類が少なすぎて、余り物が足りないケース
        if (k - i >= remainsum.size()) continue;
        
        // bestからx個、remainからK-x個貪欲に選ぶ
        ans = max(ans, bestsum[i] + remainsum[k - i] + i * i);
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 8820
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
 
   ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
   
	ll a,b;
	
	cin >> a >> b;
	
	if((a*500)>=b){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
   
return 0;   
}


Measured memory_bytes: 3644
import java.util.Scanner;

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

		String a = sc.next();
		
		int priceRamen = 700;
		int ans = priceRamen;
		
		for (int i = 0; i < 3; i++) {
			if (a.charAt(i) == 'o'){
				ans += 100;
			}
		}
		
		System.out.println(ans);
	}
}

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

bool check(vector<string> board)
{
	for (int i=0;i<8;i++)
	{
		if (count(board[i].begin(),board[i].end(),'Q')!=1) return false;
		int cnt=0,cnt1=0,cnt2=0,cnt3=0,cnt4=0;
		for (int j=0;j<8;j++)
		{
			if (board[i][j]=='Q') cnt++;
		}
		if (cnt!=1) return false;
		for (int j=0;j<i+1;j++)
		{
			if (board[i-j][j]=='Q') cnt1++;
			if (board[i-j][7-j]=='Q') cnt2++;
		}
		if (cnt1>1 || cnt2>1) return false;
		for (int j=0;j<8-i;j++)
		{
			if (board[i+j][j]=='Q') cnt3++;
			if (board[i+j][7-j]=='Q') cnt4++;
		}
		if (cnt3>1 || cnt4>1) return false;
	}
	return true;
}

int main()
{
	int K;cin >> K;
	vector<pair<int,int>> state(K);
	int x,y;
	for (int i=0;i<K;i++)
	{
		cin >> x >>y;
		state[i]=make_pair(x,y);
	}
	vector<int> num={0,1,2,3,4,5,6,7};
	do
	{
		bool can=true;
		for (int i=0;i<K;i++)
		{
			x=state[i].first;
			y=state[i].second;
			if (num[x]!=y) can=false;;
		}
		if (!can) continue;
		vector<string> board(8,"........");
		for (int i=0;i<8;i++) board[i][num[i]]='Q';
		if (check(board))
		{
			for (int i=0;i<8;i++)
			{
				cout << board[i] << endl;
			}
			break;
		} 
	} while (next_permutation(num.begin(),num.end()));
	
	return 0;
}



Measured memory_bytes: 3192
let () =
  let sl = Str.split (Str.regexp " ") (read_line ()) in
  let il = List.map int_of_string sl in
  let (a, b, c) = (List.nth il 0), (List.nth il 1), (List.nth il 2) in
  let result = if (a < b && b < c) then "Yes" else "No" in
  Printf.printf	"%s\n" result

Measured memory_bytes: 2204
using System;
class p
{
  static void Main()
  {
    int K = int.Parse(Console.ReadLine());
    string S = Console.ReadLine();
    if (S.Length <= K) {
      Console.WriteLine(S);
    } else {
      Console.WriteLine(S.Substring(0, K) + "...");
    }
  }
}

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

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

Measured memory_bytes: 1400
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 998244353;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
int a[2005];
bitset<4000005>dp;
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	int sum = 0;
	rep(i, n)sum += a[i];
	dp[0] = 1;
	rep(i, n) {
		dp |= (dp << a[i]);
	}
	for (int i = (sum + 1) / 2; i <= sum;i++) {
		if (dp[i]) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1664
#pragma GCC optimize("Ofast")

#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<climits>//上限値
// #include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


void printVector(const std::vector<double>& vec) {
	for (double value : vec) {
		std::cout << value << " ";
	}
	std::cout << std::endl;
}


int main(){
	int a,b;
	std::cin >> a >> b;
	std::cout << a*b << '\n';
	return 0;
}


Measured memory_bytes: 3636
/*
	author: zhaodeyin
	time: 2018.3.17
*/
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
typedef long long LL;
char blue[105][20];
char red[105][20];
map<string,int>add,sub;
int ans[205];
int main(){
	int n,m;
	cin>>n;
	for(int i = 1; i <= n; i++) {
		cin>>blue[i];
		add[blue[i]]++;
	}
	cin>>m;
	for(int i = 1; i <= m; i++){
		cin>>red[i];
		sub[red[i]]++;
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		int t = add[blue[i]];
		int x = sub[blue[i]];
		ans[++cnt] = t-x;
	}
	sort(ans+1,ans+1+cnt);
	if(ans[cnt]>0) cout<<ans[cnt]<<endl;
	else cout<<"0"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int N,M,i,j,k,a;
    //N : ??????????????°???M : ?????????????????°
    //num[1010] : ???????????´??°???k : ??????????????????1.2.3.4...
    int num[1010];
    scanf("%d %d",&N,&M);
    for(i = 1;i <= N;i++){
        scanf("%d",&num[i]);
    }
    for(k = 1;k <= M;k++){
        for(i = 1;i <= N;i++){
            if(1 <= i && i <=N - 1){
                if(num[i] % k > num[i + 1] % k){
                    a = num[i];
                    num[i] = num[i + 1];
                    num[i + 1] = a;
                }

            }
        }
    }
    for(i = 1;i <= N;i++){
        printf("%d\n",num[i]);
    }


    return 0;
}

Measured memory_bytes: 1860
#include <iostream>
#include <string>
#include <stdlib.h>
#define substr(source,a,b,destination) destination="";for(int i=a;i<b;i++)destination+=source[i]
using namespace std;

int main(void){
	string str;

	while(getline(cin,str)){
		for(int cif=0;cif!=26;cif++){
				for(int i=0;i<str.length();i++){
					if('A'<=str[i]&&str[i]<='Z'){
						str[i]=(str[i]-'A'+1)%26+'A';
					}else if('a'<=str[i]&&str[i]<='z'){
						str[i]=(str[i]-'a'+1)%26+'a';
					}
				}
			for(int i=0;i<str.length();i++){
				string g="";
				int j=i;
				while(i!=str.length()&&str[i]!=' ')g+=str[i++];
				if(g=="that" || g=="the"||g=="this"){
					cout<<str<<endl;
					break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
 
using namespace std;
 
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
 
typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;
 
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}
 
template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}
 
mt19937 rnd(time(NULL));
 
const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = INF + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 510;

int n, k;
int a[N];
 
bool read() {
	if (scanf("%d%d", &n, &k) != 2)
		return false;
	forn(i, n) scanf("%d", &a[i]);
	return true;
}

int ans;

void check(int m) {
	vector<int> cur;
	forn(i, n) cur.pb(a[i] % m);
	sort(all(cur));
	li suml = 0, sumr = 0;
	forn(i, n) sumr += m - cur[i];
	forn(i, n) {
		//cerr << suml << " " << sumr << endl;
		if (max(suml, sumr) <= k) {
			ans = max(ans, m);
			return;
		}
		suml += cur[i];
		sumr -= m - cur[i];
	}
	if (max(suml, sumr) <= k)
		ans = max(ans, m);
}

void solve() {
	ans = 0;
	int sum = 0;
	forn(i, n) sum += a[i];
	for (int i = 1; i * i <= sum; i++) {
		if (sum % i == 0) {
			check(i);
			check(sum / i);
		}
	}
	printf("%d\n", ans);
}
 
int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
 
	int tt = clock();
 
#endif
 
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;
	
#ifdef _DEBUG
	while (read()) {	
#else
	if (read()) {
#endif
		solve();
 
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif
 
	}
}


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

const int inf = 0x3f3f3f3f;
int mincost[(1 << 12) + 5];

int main() {
  int n, m;
  cin >> n >> m;
  
  mincost[0] = 0;
  for (int i = 1; i < (1 << n); i++)
    mincost[i] = inf;
  
  for (int i = 0; i < m; i++) {
    int a, b, m = 0;
    cin >> a >> b;
    for (int j = 0; j < b; j++) {
      int t; cin >> t;
      t--;
      m |= 1 << t;
    }
    for (int j = 0; j < (1 << n); j++)
      mincost[j | m] = min(mincost[j | m], mincost[j] + a);
  }
  
  if (mincost[(1 << n) - 1] == inf) {
    cout << -1 << endl;
  } else {
  	cout << mincost[(1 << n) - 1] << endl;
  }
}

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

int main()
{
  char s[1001], t[1001];
  std::cin >> s >> t;
  int slen = strlen(s);
  int tlen = strlen(t);
  int min = tlen;
  for (int i=0;i<=slen-tlen;++i)
  {
    int diff = 0;
    for (int j=0;j<tlen;++j)
    {
      if (s[i+j] != t[j])diff++;
    }
    if (min > diff) min = diff;
  }
  std::cout << min;
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void);

int main(void)
{
    int H, W, i, j;

    while(1){
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0){
            break;
        }

        for(i = 1; i <= H; i++){
            for(j = 1; j <= W; j++){
                if(i % 2 == 0){
                    if(j % 2 == 0){
                        printf("#");
                    }
                    else{
                        printf(".");
                    }
                }
                else{
                    if(j % 2 == 0){
                        printf(".");
                    }
                    else{
                        printf("#");
                    }
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return(0);
}


Measured memory_bytes: 2072