akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(int argc, char*argv[])
{
  for(;;) {
    int P, C, W, S;
    cin >> P;
    if(P==0) break;
    cin >> C >> W >> S;
    vector<string> lines;
    string line;
    int n = 0;
    getline(cin, line); // to skip the first one 
    for(;;) {
      getline(cin, line);
      if(line == "?") break;
      lines.push_back(line);
      n++;
    }
    auto printpage=[&](vector<vector<string>> &page) {
      int LS = W*C+(C-1)*S;
      char pp[P][LS+1];
      for(int i = 0; i < P; i++) {
        for(int j = 0; j < LS; j++) {
          pp[i][j] = '.';
        }
        pp[i][LS] = 0;
      }
      for(int c = 0; c < page.size(); c++) {
        for(int s = 0; s < page[c].size(); s++) {
          for(int k = 0; k < page[c][s].size(); k++) {
            pp[s][c*W+c*S + k] = page[c][s][k];
          }
        }
      }
      for(int i = 0; i < P; i++) {
        cout << pp[i] << endl;
      }
      cout << "#" << endl;
    };
    vector<vector<string>> page;
    vector<string> col;
    for(int i = 0; i < n;) {
      if(lines[i].length() > W) {
        col.push_back(lines[i].substr(0, W));
        lines[i] = lines[i].substr(W);
      } else {
        col.push_back(lines[i]);
        i++;
      }
      if(col.size() == P) {
        page.push_back(col);
        col.clear();
      }
      if(page.size() == C) {
        printpage(page);
        page.clear();
      }
    }
    if(col.size() > 0) {
      page.push_back(col);
    }
    if(page.size() > 0) {
      printpage(page);
    }
    cout << "?" << endl;
  }
  return 0;
}

Measured memory_bytes: 3208
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

typedef map<int, int>::iterator iter;

map<int, int> mp1, mp2;

int n, m;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int t = 0;
        scanf("%d", &t);
        mp1[t]++;
    }
    scanf("%d", &m);
    for (int i = 1; i <= m; i++) {
        int t = 0;
        scanf("%d", &t);
        mp2[t]++;
    }
    bool ans = true;
    for (iter i = mp2.begin(); i != mp2.end(); i++) {
        if (i->second > mp1[i->first]) ans = false;
    }
    if (ans) printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 18944
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

typedef long long Weight;
Weight const inf = 1LL<<60;

struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight) :
        src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

struct State {
    int v,d;
    State(int v, int d): v(v),d(d){}
    bool operator<(const State& s)const{
        return d>s.d;
    }
};

void dijkstra(Graph const &g, int s, vector<Weight> &dist) {
    priority_queue<State> q;
    dist.assign(g.size(), inf); dist[s] = 0;
    q.push(State(s, 0));
    while (q.size()) {
        State s = q.top(); q.pop();
        int v = s.v;
        if (dist[v] < s.d) continue;
        rep(i,g[v].size()){
            const Edge &e = g[v][i];
            if (dist[e.dst] > dist[v] + e.weight) {
                dist[e.dst] = dist[v] + e.weight;
                q.push(State(e.dst, dist[e.dst]));
            }
        }
    }
}

int main(){
    int V,E,r;
    while(cin>>V>>E>>r){
        Graph g(V);
        rep(i,E){
            int a,b;
            Weight c;
            cin>>a>>b>>c;
            g[a].push_back(Edge(a,b,c));
        }
        vector<Weight> d;
        dijkstra(g,r,d);
        rep(i,V){
            if(d[i]==inf) cout<<"INF";
            else cout<<d[i];
            cout<<endl;
        }
    }
}

Measured memory_bytes: 16588
#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>
#include <string>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#include <stack>

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long
const int INF = 1 << 29;
const ll llINF = 10000000000000000;

const int MOD = 1000000007;

#define MAX_N 100100
typedef pair<int, int> P;
typedef pair<ll, ll> llP;

class UnionFindTree{
private:
    int par[MAX_N];
    int urank[MAX_N];
    int size[MAX_N];
public:
    int init(int n);
    int find(int x);
    int unite(int x, int y);
    int same(int x, int y);
    int parnum(int x){return par[x];}
    int ranknum(int x){return urank[x];}
    int sizenum(int x){return size[find(x)];}
};

int UnionFindTree::init(int n){
    REP(i, n){
        par[i] = i;
        urank[i] = 0;
        size[i] = 1;
    }
    return 0;
}

int UnionFindTree::find(int x){
    if(par[x] == x)return x;
    else return par[x] = find(par[x]);
}

int UnionFindTree::unite(int x, int y){
    x = find(x);
    y = find(y);
    
    if(x == y)return 0;
    if(urank[x] < urank[y]){
        par[x] = y;
        size[y] += size[x];
    }else{
        par[y] = x;
        size[x] += size[y];
        if(urank[x] == urank[y])urank[x] ++;
    }
    return 0;
}

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

bool ue[510] = {true};
class Jishojun{
public:
    bool operator()(const P& riLeft, const P&riRight){
        return (riLeft.first < riRight.first || (riLeft.first == riRight.first && ((ue[riLeft.first] && riLeft.second < riRight.second) || (!ue[riLeft.first] && riLeft.second > riRight.second))));
    }
};

int gojohou(int a,int b){
    if(b == 0)return a;
    return gojohou(b,  a % b);
}
int main(){
    int saisho;
    cin >> saisho;
    int a[3];
    a[0] = saisho / 100;
    saisho -= a[0] * 100;
    a[1] = saisho / 10;
    saisho -= a[1] * 10;
    a[2] = saisho;
    REP(i, 3){
        printf("%d", 10 - a[i]);
    }
}


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

int main()
{
  const int MAX_PRIME = 10000+1;

  bool p[MAX_PRIME];
  memset(p, true, sizeof(p));
  p[0] = p[1] = false;
  for (int i = 2; i*i <= MAX_PRIME; ++i) {
    if (p[i]) {
      for (int j = i+i; j < MAX_PRIME; j += i)
	p[j] = false;
    }
  }

  vector<int> prime;
  for (int i = 0; i < MAX_PRIME; ++i) {
    if (p[i])
      prime.push_back(i);
  }

  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    for (int i = prime.size()-1; i > 0; --i) {
      if (prime[i]-2 == prime[i-1] && prime[i] <= n) {
	cout << prime[i-1] << " " << prime[i] << endl;
	break;
      }
    }
  }
  return 0;
}

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

int main() {
  char x;
  cin >> x;
  if (x == 'A') {
    cout << "T" << endl;
  }
  else if (x == 'T') {
    cout << "A" << endl;
  }
  else if (x == 'C') {
    cout << "G" << endl;
  }
  else if (x == 'G') {
    cout << "C" << endl;
  }
}

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

using namespace std;

// long long comb(const long long a, const long long b){
//   long long mod = 1000000007;
//
//   long long fact[a + 1];
//   long long inv[a + 1];
//   fact[0] = 1;
//   inv[0] = 1;
//
//   for(long long i = 1; i <= a; i++){
//     fact[i] = (fact[i-1] * i) % mod;
//
//     long long ans = 1;
//     long long n = mod-2;
//     long long x = fact[i];
//     while(n > 0){
//       if((n & 1) == 1){
//         ans = (ans * x) % mod;
//       }
//       x = (x * x) % mod;
//       n >>= 1;
//     }
//     inv[i] = ans % mod;
//     cout << fact[i] << " " << inv[i] << endl;
//   }
//   return (fact[a] * inv[b] * inv[a-b]) % mod;
// }
#define ll long long
ll mo=1000000007;
ll comb(ll N_, ll C_) {
	const int NUM_=400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}

ll modpow(ll a, ll n) {
	ll r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

ll comb(int P_,int Q_) {
	if(P_<0 || Q_<0 || Q_>P_) return 0;
	ll p=1,q=1;
	Q_=min(Q_,P_-Q_);
	for(int i=1;i<=Q_;i++) p=p*P_%mo, q=q*i%mo,P_--;

	return p*modpow(q,mo-2)%mo;
}

int main(){
  long long mo = 1000000007;
  long long n, m, k;
  cin >> n >> m >> k;
  int x = 0;
  int y = 0;

  for(long long i = 1 ; i < n ; i++){
    long long d = (i * (n-i))%mo;
    x += d;
    x = x%mo;
  }
  for(long long i = 1 ; i < m ; i++){
    long long d = (i * (m-i))%mo;
    y += d;
    y = y%mo;
  }
  cout << ((x*m*m+y*n*n)%mo * comb(n*m-2, k-2)) %mo << endl;
  // cout << comb(18, 2) << endl;
}


Measured memory_bytes: 9600
#include <iostream>
using namespace std;
int main(void){
    long long int n,k,l[50],ho[50],pl=2000000000000,total=0,s[50],totalm=0,count=0,j=-1;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>l[i];
        s[i]=0;
        total+=l[i];
        ho[i]=l[i];
    }
    while(count<n-k){
        j++;
        pl=2000000000000;
        for(int i=0;i<n;i++){
            if(l[i]<pl){
                pl=l[i];
                s[j]=i;
            }
            if(i==n-1){
                totalm+=l[s[j]];
                l[s[j]]=2000000000000;
            }
        }
        count++;
    }
    cout<<total-totalm<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int  main(){
    ll n,m;
    cin>>n>>m;
    //n个s形状，m个c形状
    cout<<min(m/2,n)+(m-min(m/2,n)*2)/4<<endl;
return 0;
}


Measured memory_bytes: 256
//インクルード(アルファベット順)
#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>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//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 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の二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

//最後のところの処理がいい加減になっていた、こういう詰めの甘い実装がダメなんだよカス
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,q;cin>>n>>q;

    vector<vector<ll>> xst(n);
    REP(i,n){
        ll s,t,x;cin>>s>>t>>x;
        xst[i]={x,s,t};
    }
    sort(ALL(xst));

    vector<ll> d(q);
    REP(i,q)cin>>d[i];

    vector<deque<ll>> ans_sectl(q);
    vector<deque<ll>> ans_sectr(q);
    REP(i,n){
        ll s,t,x;x=xst[i][0];s=xst[i][1];t=xst[i][2];
        ll L=(lower_bound(ALL(d),s-x)-d.begin());
        ll R=(upper_bound(ALL(d),t-x-1)-d.begin())-1;
        //lower,upper気を付ける
        //2RE
        if(L!=q and R!=-1){ans_sectl[L].PB(i);ans_sectr[R].PB(i);}
        //cout << L << " " << R << endl;
    }

    //複数存在する場合もあるので、map
    map<ll,ll> ans;
    REP(i,q){
        ll sl=SIZE(ans_sectl[i]);
        ll sr=SIZE(ans_sectr[i]);
        REP(_,sl){
            ans[*(ans_sectl[i].begin())]+=1;
            ans_sectl[i].pop_front();
        }
        while(!ans.empty()){
            if(ans.begin()->S==0){
                ans.erase(ans.begin());
            }else{
                break;
            }
        }
        if(ans.empty()){
            cout<<-1<<"\n";
        }else{
            cout<<xst[ans.begin()->F][0]<<"\n";
        }
        #if 0
        if(i==q-1){
            for(auto& e:ans)cout<<xst[e.F][0]<<endl;
        }
        #endif
        REP(_,sr){
            ans[*(ans_sectr[i].begin())]-=1;
            ans_sectr[i].pop_front();
        }
    }
}

Measured memory_bytes: 296984
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int a,b,x; cin>>a>>b>>x;
    if(x<a||a+b<x) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}

Measured memory_bytes: 256
import sys
from bisect import bisect

fin = sys.stdin.readline
A, B, Q = [int(elem) for elem in fin().split()]
s_list = tuple([-float('inf')]) + tuple(int(fin()) for _ in range(A)) + tuple([float('inf')])
t_list = tuple([-float('inf')]) + tuple(int(fin()) for _ in range(B)) + tuple([float('inf')])
x_list = tuple(int(fin()) for _ in range(Q))


def search_shortest_dist(s_list, t_list, x):
    s_closest_idx = bisect(s_list, x)
    t_closest_idx = bisect(t_list, x)
    min_dist = float('inf')
    for s_idx in (s_closest_idx - 1, s_closest_idx):
        s = s_list[s_idx]
        for t_idx in (t_closest_idx - 1, t_closest_idx):
            t = t_list[t_idx]
            if s <= t <= x:
                dist = x - s
            elif s <= x <= t:
                dist = t - s + min(x - s, t - x)
            elif t <= s <= x:
                dist = x - t
            elif t <= x <= s:
                dist = s - t + min(x - t, s - x)
            elif x <= s <= t:
                dist = t - x
            else:  # x <= t <= s
                dist = s - x
            min_dist = min(min_dist, dist)
    return min_dist


for x in x_list:
    print(search_shortest_dist(s_list, t_list, x))


Measured memory_bytes: 82780
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

from itertools import combinations
from functools import reduce
from collections import Counter

primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

def prime_factorization(x):
  # 100までの素数でしか動かない
  facters = []

  if x == 1:
    return [1]

  if x in primes:
    return [x]

  for p in primes:
    while x%p == 0:
      x /= p
      facters += [p]
  return facters


facters = {i:prime_factorization(i) for i in range(1, 100+1)}

def main():
  n = int(input())

  nn = []
  for i in range(2, n+1):
    nn += facters[i]
  nn = [x+1 for x in Counter(nn).values()]
  count_5 = 0
  count_3 = 0
  count_15 = 0
  count_25 = 0
  count_75 = 0
  f = lambda x: x*f(x-1) if x>1 else 1
  comb = lambda x,y: int(f(x) / (f(y)*f(x-y))) if y<=x else 0
  for x in nn:
    if 75 <= x:
      count_75 += 1
    if 25 <= x:
      count_25 += 1
    if 15 <= x:
      count_15 += 1
    if 5 <= x:
      count_5 += 1
    if 3 <= x:
      count_3 += 1

  counts = [count_3, count_5, count_15, count_25, count_75] # length: 5

  ans = comb(count_5, 2) * (count_3 - 2) \
      + count_15 * (count_5 - 1) \
      + count_25 * (count_3 - 1) \
      + count_75
  print(ans)

if __name__=='__main__':
  main()

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

int main(){
  int H,N;
  cin >> H >> N;
  for (int i=0;i<N ;i++){
    int a;
    cin >> a;
    H -= a;
  }
  if(H > 0){
    cout << "No" <<endl;
  }
  else cout << "Yes" <<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
# n = int(input())

# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache

input = sys.stdin.readline

# N個整数
x, y, z, kk = list(map(int, input().split()))

# 1整数
# n = int(input())

# 空白区切りリスト整数
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)


ll = []
count = 0
for i in range(len(a)):
    for j in range(len(b)):
        if i * j > kk:

            break
        for k in range(len(c)):
            if i * j * k > kk:
                break
            ll.append(a[i] + b[j] + c[k])
ll.sort(reverse=True)

for i in range(kk):
    print(ll[i])

# 空白区切り文字列
# t, d = input().split()


Measured memory_bytes: 105480
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);



signed main(){
  int a[3];
  rep(i,3)cin >> a[i];
  sort(a, a + 3);
  cout << a[0] + a[1] << endl;
  return 0;
}






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

int _main(){
    
    int h,w;
    cin >> h >> w;  
    int _sx,_sy,sx,sy;
    cin >> _sy >> _sx;  
    int _gx,_gy,gx,gy;
    cin >> _gy >> _gx;
    sx = _sx-1; sy = _sy-1;
    gx = _gx-1; gy = _gy-1;

    vector<vector<bool>> road(w, vector<bool>(h));
    for (int y=0; y<h; y++) {
        for (int x=0; x<w; x++) {
            char c;
            cin >> c;
            if(c=='.'){
                road.at(x).at(y)=true;
            }else{
                road.at(x).at(y)=false;
            }
        }
    }

    vector<vector<int>> cost(w, vector<int>(h,INFINITY));
    queue<tuple<int,int>> searchfrom;
    vector<vector<int>> searching_b(w, vector<int>(h,false));
    searchfrom.push(tuple<int,int>(sx,sy));
    int costnow = 0;
    while(true){
        queue<tuple<int,int>> searching = queue<tuple<int,int>>(searchfrom);
        queue<tuple<int,int>> searched  = queue<tuple<int,int>>();
        searchfrom = queue<tuple<int,int>>();
        while(searching.size()>0){
            tuple<int,int> coord = searching.front();
            int cx = get<0>(coord); int cy = get<1>(coord);
            searching.pop();


            if(cx==gx && cy==gy){
                return costnow;
            }

            for(int x=max(0,cx-1); x<=min(w-1,cx+1); x++){
                for(int y=max(0,cy-1); y<=min(h-1,cy+1); y++){
                    int lenSu = abs(x-cx)+abs(y-cy);
                    if(road.at(x).at(y) && costnow<cost.at(x).at(y)){
                        if(lenSu==0){
                            cost.at(x).at(y) = costnow;
                            searching_b.at(x).at(y)=true;
                            searched.push(tuple<int,int>(x,y));
                        }else if(lenSu==1 && !searching_b.at(x).at(y)){
                            searching_b.at(x).at(y)=true;
                            searching.push(tuple<int,int>(x,y));
                        }
                    }
                }
            }
        }
        while(searched.size()>0){
            tuple<int,int> coord = searched.front();
            int cx = get<0>(coord); int cy = get<1>(coord);
            searched.pop();

            for(int x=max(0,get<0>(coord)-2); x<=min(w-1,get<0>(coord)+2); x++){
                for(int y=max(0,get<1>(coord)-2); y<=min(h-1,get<1>(coord)+2); y++){
                    if(road.at(x).at(y) && costnow<cost.at(x).at(y)){
                        searchfrom.push(tuple<int,int>(x,y));
                    }
                }
            }
        }
        if(searchfrom.size()==0) return -1;
        costnow++;
    }
}

int main(){
    int result = _main();
    cout << result;
    return 0;
}

Measured memory_bytes: 11872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ACはうれCすぎてうれD */

int main(void){
    int n;
    cin >> n;
    map<pair<string,int>, int > mp;
    map<pair<string,int>, int >::iterator itr;
    for(int i=0; i<n; i++){
        string s;
        int p;
        cin >> s;
        cin >> p;
        mp[{s,100-p}] = i+1;
    
    }
    for(itr = mp.begin(); itr != mp.end(); itr++){ 
        cout << itr->second << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define pb push_back
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
using namespace std;
int main()
{
	ll i,n,j=0;
	string a;
	cin>>a;
	n=a.size();
	if(n==1&&a[0]=='?')
	{
		a[0]='D';
	}
//	ll a[n];
	for1(i,n)
	{
		if(a[0]=='?'&&a[1]=='D')
		a[0]='P';
		else if(a[0]=='?'&&a[1]=='?')
		{
			a[0]='P';
			a[1]='D';
			i++;
		}
		else if(a[0]=='?')
		a[0]='D';
		if(a[i-1]=='P'&&a[i]=='?'||(i==n-1&&a[i]=='?')||(a[i]=='?'&&a[i+1]=='P'))	
		a[i]='D';
		else if(a[i]=='?')
		a[i]='P';
	}
	
	for0(i,n)
	cout<<a[i];
	cout<<endl;
}


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

#define INF 1 << 29

#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)
using namespace std;

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


int n;
double v[102], t[102];

int rui[102];
double ans = 0;

double min_f(double now){
  double mi = INF;
  REP(i,n+2){
    if(now >= rui[i]){
      mi = min(mi, v[i]+abs(now-rui[i]));
    }else if(now < rui[i-1]){
      mi = min(mi, v[i]+abs(now-rui[i-1]));
    }else{
      mi = min(mi,v[i]);
    }
  }
  //cout << mi << " ";
  return mi;
}

double s(double now){
  return 0.25*(min_f(now)+min_f(now+0.5));
}

int main(){
  cin >> n;
  rui[0] = 0;
  FOR(i,1,n+1){
    cin >> t[i];
    rui[i] = rui[i-1]+t[i];
  }
  rui[n+1] = INF;
  FOR(i,1,n+1){
    cin >> v[i];
  }
  for(double now = 0; now <= rui[n];now += 0.5){
    //cout << endl << now << " ";
    ans += s(now);
  }
  printf("%.6f\n",ans);
}

/*
int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}

int n, t[100],v[101];

vector<ppi> vec;//time,velocity
int main(){
  scanf("%d",&n);
  REP(i,n) scanf("%d",&t[i]);
  REP(i,n) scanf("%d",&v[i]);
  v[n] = 0;
  vec.push_back(ppi(0,0));
  REP(i,n){
    if(t[i+1]-t[i] >= abs(v[i+1]-v[i])){//
      if(t[i+2]-t[i+1] >= abs(v[i+2]-v[i+1])){//問題ない時
        sum += (v[i] + v[i+1])*abs'(v[i+1]-v[i])/2 + max(v[i+1],v[i]) * (t[i+1]-t[i] - (v[i+1]-v[i]));
      }else{
        t[i+1] = t[i] + (t[i+2]-t[i]-abs(v[i+2]-v[i]))/2;
        v[i+1] = v[i] + 
      }

    }
  }
}
*/


Measured memory_bytes: 256
//Author : Vipul Sharma

// LIBRARIES
#include <bits/stdc++.h>

// MACROS
#define ll long long int
#define ld long double
#define rep(i, a, b) for (i = a; i < b; i++)
#define rev(i,b,a) for(i=b-1;i>=a;i--)
#define s1rep(i,a,b) for( i=1;i<=b;i++)
#define itrep(at) for (auto it = at.begin(); it != at.end(); it++)
#define ld long double
#define pb push_back
#define w(t) while (t--)
#define booster                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define deb1(x) cout << #x << " : " << x << endl;
#define deb2(x, y) cout << #x << " : " << x << "\t" << #y << " : " << y << endl;
#define deb3(x, y, z) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << endl;
#define deb4(x, y, z, w) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << "\t" << #w << " : " << w << endl;
#define deb5(a, b, c, d, e) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define deb6(a, b, c, d, e, f) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

using namespace std;
long long cost = 1e18;


int main()
{
	
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

	ll a;
	string b;
	cin>>a>>b;
	ll c=(b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0');
	cout<<(a*c)/100<<endl;
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#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 uni(x) x.erase(unique(rng(x)),x.end())
#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) vector<vector<T>>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
inline int in() { int x; cin>>x; return x;}
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
#define dame {puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
//----------------------------------------------------------------
int main(int argc,char* argv[]){
    fileio
    vi dp(MX,INF);
    int n = in();
    vi h(n);
    cin>>h;
    h.pb(INF);
    h.pb(INF);
    dp[0] = 0;
    rep(i,n){
        mins(dp[i+1], dp[i]+abs(h[i]-h[i+1]));
        mins(dp[i+2], dp[i]+abs(h[i]-h[i+2]));
    }
    cout<<dp[n-1]<< endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

ll cando(ll index){
    ll count=0;
    while(true){
        if(index%2==0){
            count++;
            index/=2;
        } else break;
    }
    return count;
}

int main(void){
    ll N;
    cin>>N;
    ll a;
    ll OUT=0;
    rep(i, N){
        cin>>a;
        OUT+=cando(a);
    }
    cout<<OUT<<endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
if s == "SUN":
  print(7)
elif s == "MON":
  print(6)
elif s == "TUE":
  print(5)
elif s == "WED":
  print(4)
elif s == "THU":
  print(3)
elif s == "FRI":
  print(2)
else:
  print(1)

Measured memory_bytes: 8980
use proconio::input;

fn prime_factorization(n: usize) -> Vec<(usize, usize)> {
    let mut p = vec![];
    if n < 2 {
        return p;
    }
    let mut n = n; // shadowing
    for i in 2.. {
        if i * i > n {
            break;
        }
        let mut c = 0;
        while n % i == 0 {
            c += 1;
            n /= i;
        }
        if c > 0 {
            p.push((i, c));
        }
    }
    if n != 1 {
        p.push((n, 1));
    }
    p
}

fn main() {
    input! {
        n: usize,
    };
    let mut dp = vec![1_usize; n + 1];
    for i in 2..=n {
        let p = prime_factorization(i);
        for &(p_i, c_i) in p.iter() {
            dp[p_i] += c_i;
        }
    }
    let ans = dp
        .iter()
        .fold(1_usize, |acc, &dp_i| (acc * dp_i) % 1_000_000_007);
    println!("{}", ans);
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    // cout << fixed << setprecision(10) << flush;

    string s;
    cin >> s;
    int a = 0, max_a = 0;
    if(s == "SSS") cout << 0 << endl;
    else if(s == "SSR") cout << 1 << endl;
    else if(s == "SRS") cout << 1 << endl;
    else if(s == "SRR") cout << 2 << endl;
    else if(s == "RSS") cout << 1 << endl;
    else if(s == "RSR") cout << 1 << endl;
    else if(s == "RRS") cout << 2 << endl;
    else if(s == "RRR") cout << 3 << endl;

    return 0;
}

Measured memory_bytes: 3628
// In The Name Of Allah //
#include <bits/stdc++.h>
#define pb emplace_back
#define inf (int)-1e9
#define ff first
#define ss second
#define ll long long
#define sp(n) cout << setprecision(n) << fixed
#define hellcat ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define give(x) cout << #x << " " << x << endl
#define debug cout << "dddd" << '\n'
#define debarr(a, n) for (int i = 0; i < n; ++i) cout << a[i] << ' '; cout << endl
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

template <class S, class T>
inline S smax(S &l, T r) {
  return l = max(l, (S)r);
}
template <class S, class T>
inline bool smin(S &l, T r) {
  return l = min(l, (S)r);
}

const int MAXN = 1e3 + 10, DELTA = 1e9 + 7;
string s[MAXN];
int dp[MAXN][MAXN];


int32_t main () {
  hellcat;

	int h, w;
	cin >> h >> w;

	for (int i = 0; i < h; ++i)
		cin >> s[i];
	
	string t = s[0];
	dp[0][0] = (t[0] == '.');
	for (int i = 0; i < h; ++i) {
		string str = s[i];
		for (int j = 0; j < w; ++j) {
			if (!i && !j)
				continue;
			if (str[j] == '#')
				continue;
			if (!i)
				dp[i][j] = dp[i][j - 1];
			else if (!j)
				dp[i][j] = dp[i - 1][j];
			else
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % DELTA;
		}
	}

	h--, w--;
	cout << dp[h][w] << '\n';

	return 0;
}


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

int main() {
    int N, M, L;
    cin>>N>>M>>L;
    vector<vector<pair<long, long>>> G(N);
    vector<pair<int, int>> Query;
    REP(i, 0, M){
        int p, q, r;
        cin >> p >> q >> r;
        p--; q--;
        if(r <= L){
            G[p].emplace_back(make_pair(q, r));
            G[q].emplace_back(make_pair(p, r)); 
        }  
    } 
    int Q;
    cin >> Q;
    REP(i, 0, Q){
        int s, t;
        cin >> s >> t;
        s--; t--;
        Query.emplace_back(make_pair(s, t));
    }
    vector<vector<long>> dist(N, vector<long>(N, (__LONG_MAX__ >> 1) ));
    REP(i, 0, N){
        dist[i][i] = 0;
        for(auto u:G[i]){
            dist[i][u.first] = u.second;
        }
    }
    REP(k, 0, N){
        REP(j, 0, N){
            if(dist[k][j] == (__LONG_MAX__ >> 1)) continue;
            REP(i, 0, N){
                long newLen = dist[i][k] + dist[k][j];
                if(dist[i][j] > newLen){
                    dist[i][j] = newLen;
                }
            }
        }
    }
    vector<vector<int>> LG(N, vector<int>(N, (__INT_MAX__ >> 1)));
    REP(i, 0, N){
        REP(j, 0, N){
            if(dist[i][j] <= L) LG[i][j] = 1;
        }
    }
    
    REP(k, 0, N){
        REP(j, 0, N){
            if(LG[k][j] == (__INT_MAX__ >> 1)) continue;
            REP(i, 0, N){
                long newLen = LG[i][k] + LG[k][j];
                if(LG[i][j] > newLen){
                    LG[i][j] = newLen;
                }
            }
        }
    }
    REP(i, 0, Q){
        int ans = LG[Query[i].first][Query[i].second];
        cout << ((ans == (__INT_MAX__>> 1))? -1 : ans - 1) << endl;
    }
    
}

Measured memory_bytes: 4616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <utility>

using namespace std;
using llong = long long;

int A[100000];
map<int,int> diffnum;

int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;++i){
    cin >> A[i];
    diffnum[A[i]]++;
    if(diffnum[A[i]]>2||(N%2==1&&diffnum[0]>1)||(N%2==A[i]%2)){
      cout << 0 << endl;
      return 0;
    }
  }

  llong pat = 1;
  for(auto p:diffnum){
    pat = (pat*p.second)%1000000007;
  }

  cout << pat << endl;

  return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> v(m + 1);
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		if (a > m) continue;
		v[a].emplace_back(b);
	}
	priority_queue<int> que;
	ll ans = 0;
	rep(i, m + 1) {
		for (auto& c : v[i]) {
			que.push(c);
		}
		if (que.size()) {
			ans += que.top();
			que.pop();
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5632
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0].split(" ")[0]);
    var i = Number(lines[0].split(" ")[1]);
    console.log(N - i + 1);

});



Measured memory_bytes: 7880
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005

string s,t,ans;

int dp[3005][3005],a[3005][3005];

pi f[3005][3005];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> s >> t;
    for(int i=1;i<=s.lg;i++){
        for(int j=1;j<=t.lg;j++){
            if(dp[i-1][j]>dp[i][j-1]) dp[i][j]=dp[i-1][j],f[i][j]={i-1,j};
            else dp[i][j]=dp[i][j-1],f[i][j]={i,j-1};
            if(s[i-1]==t[j-1] && dp[i-1][j-1]+1>dp[i][j]) dp[i][j]=dp[i-1][j-1]+1,f[i][j]={i-1,j-1},a[i][j]=1;
        }
    }
    pi x={s.lg,t.lg};
    while(x.x && x.y){
        if(a[x.x][x.y]) ans+=s[x.x-1];
        x=f[x.x][x.y];
    }
    reverse(ans.begin(),ans.end());
    cout << ans;
}


Measured memory_bytes: 141312
N, Y =map(int,input().split(" "))
for i in range(N+1):
    for j in range(N-i+1):
        if i * 10000 + j*5000 + (N-i-j)*1000 ==Y:
            print(i, j, N-i-j)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	fmt.Println((n * (n + 1)) / 2)
}


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

int main() {
  int n, u, v;
  cin >> n >> u >> v;
  vector<vector<int>> t(n);
  for(int i = 0; i < n - 1; ++i){
    int a, b;
    cin >> a >> b;
    t[a-1].push_back(b-1);
    t[b-1].push_back(a-1);
  }
  
  vector<int> du(n, 100000000);
  du[u-1] = 0;
  queue<int> qu;
  qu.push(u-1);
  while(!qu.empty()){
    int tmp = qu.front();
    qu.pop();
    for(int i: t[tmp]){
      if(du[i] > du[tmp] + 1){
        du[i] = du[tmp] + 1;
        qu.push(i);
      }
    }
  }

  vector<int> dv(n, 100000000);
  dv[v-1] = 0;
  queue<int> qv;
  qv.push(v-1);
  while(!qv.empty()){
    int tmp = qv.front();
    qv.pop();
    for(int i: t[tmp]){
      if(dv[i] > dv[tmp] + 1){
        dv[i] = dv[tmp] + 1;
        qv.push(i);
      }
    }
  }

  int r = 0;
  for(int i = 0; i < n; ++i){
    if(du[i] > dv[i]) continue;
    else r = max(r, dv[i] - 1);
  }
  cout << r << endl;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define ll long long
#define coYes cout << "Yes" << endl
#define coYES cout << "YES" << endl
#define coyes cout << "yes" << endl
#define coNo cout << "No" << endl
#define coNO cout << "NO" << endl
#define cono cout << "no" << endl
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
int gcd(int a, int b){ //最大公約数
    if(a%b == 0){
        return b;
    }else{
    return gcd(b, a%b);
    }
}

int main(){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    rep0(i,s.length()-1){
        if(s[i]==s[i+1]){
            cono;
            return 0;
        }
    }
    coyes;
    return 0;
}

Measured memory_bytes: 3604
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            //N:0,W:1,S:2,E:3
            int[] cnt = new int[4];
            for (int i = 0; i < S.length(); i++) {
                if (S.charAt(i) == 'N') cnt[0]++;
                if (S.charAt(i) == 'W') cnt[1]++;
                if (S.charAt(i) == 'S') cnt[2]++;
                if (S.charAt(i) == 'E') cnt[3]++;
            }
            boolean ok = false;
            if (cnt[0] > 0 && cnt[2] > 0 && cnt[1] == 0 && cnt[3] == 0) ok = true;
            if (cnt[0] == 0 && cnt[2] == 0 && cnt[1] > 0 && cnt[3] > 0) ok = true;
            if (cnt[0] > 0 && cnt[2] > 0 && cnt[1] > 0 && cnt[3] > 0) ok = true;

            out.println(ok ? "Yes" : "No");

        }

    }
}



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

int main(){
    int n,d;
    cin >> n >> d;
    vector<vector<int>> x(n,vector<int>(d));
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            cin >> x.at(i).at(j);
        }
    }
    double dis = 0;
    int ans = 0;
    for(int i=0; i<=n; i++){
        for(int j=1; j<i; j++){
            for(int k=0; k<d; k++){
                dis += abs((x.at(i-1).at(k) - x.at(j-1).at(k))*(x.at(i-1).at(k) - x.at(j-1).at(k)));
            }
            dis = sqrt(dis);
            int nbool = dis;
            if(dis == nbool){
                ans += 1;
            }
            dis = 0;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

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

  vector<bool> visited(N, false);
  int idx = 0;
  int cnt = 0;
  while (true) {
    if (visited[idx]) {
      cout << -1 << endl;
      return 0;
    }
    if (idx == 1) break;
    visited[idx] = true;
    idx = a[idx];
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;

int main(){
    int n;
    std::cin >> n;
    std::vector<ll> a(n),b(n);
    rep(i,n)std::cin >> a[i];
    rep(i,n)std::cin >> b[i];
    if(sum(all(a),0ll)<sum(all(b),0ll)){
        std::cout << -1 << std::endl;
        exit(0);
    }
    std::vector<ll> g;
    ll di=0ll;
    int ans=0;
    rep(i,n){
        if(a[i]>b[i])g.pb(a[i]-b[i]);
        if(a[i]<b[i]){
            ans++;
            di+=b[i]-a[i];
        }
    }
    sort(all(g),greater<ll>());
    int i=0;
    while(di>0ll){
        di-=g[i];
        i++;
        ans++;
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 2428
#include<cstdio>
#include<cctype>
using namespace std;
int main(void)
{
	char ch;
	while(1){
		scanf("%c",&ch);
		if(isalpha(ch)){
			if(islower(ch)) printf("%c",toupper(ch));
			else printf("%c",tolower(ch));
		}else printf("%c",ch);
		if(ch=='\n') break;
	}
	return 0;
}


Measured memory_bytes: 2692
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;

signed main(){
	cin>>N;
	int R=N;
	set<P> U;
	vector<P> v;
	if(N%2==0){
		R++;
	}
	for(int i=1;i<=R;i++){
		U.insert({i,R-i});
	}
	for(int i=1;i<=N;i++){
		for(int j=i+1;j<=N;j++){
			if(U.find({i,j})==U.end()){
				v.push_back({i,j});
			}
		}
	}
	cout<<v.size()<<endl;
	REP(i,v.size()){
		cout<<v[i].first<<" "<<v[i].second<<endl;
	}
	return 0;
}


Measured memory_bytes: 512
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int H, N, A[int(1e3 + 5)], B[int(1e3 + 5)];
int DP[int(2e4 + 5)];

int main(){
  scanf("%d%d", &H, &N);
  for (int i = 0; i < N; i++) scanf("%d%d", A + i, B + i);
  fill(DP + 1, DP + 20005, 1e9);

  for (int i = 0; i < N; i++){
    for (int j = 0; j + A[i] < 2e4 + 5; j++){
      DP[j + A[i]] = min(DP[j + A[i]], DP[j] + B[i]);
    }
    for (int j = 2e4 + 3; j >= 0; j--){
      DP[j] = min(DP[j], DP[j + 1]);
    }
  }
  printf("%d\n", DP[H]);

  return 0;
}


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

int main(){
    using namespace std;
    unsigned long N, M;
    while((cin >> N >> M) && N && M){
        deque<unsigned long> A(N), B(M);
        for(auto& i : A)cin >> i;
        for(auto& i : B)cin >> i;
        A.push_front(0);
        B.push_front(0);
        partial_sum(A.begin(), A.end(), A.begin());
        partial_sum(B.begin(), B.end(), B.begin());
        vector<unsigned long> T(1 + A.back() + B.back());
        for(const auto i : A)
            for(const auto j : B)++T[i + j];
        cout << accumulate(T.begin(), T.end(), 0UL, [](auto a, auto b){return a + b * (b - 1) / 2;}) << endl;
    }
}


Measured memory_bytes: 12064