akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int h, w, d;
int a[310][310];
map<int, P> mp;
int u[20][90010];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w >> d;
    rep(i, 0, h){
        rep(j, 0, w){
            cin >> a[i][j];
            a[i][j]--;
            mp[a[i][j]] = P{i, j};
        }
    }
    rep(i, 0, h * w){
        int next = i + d;        
        if(next <= h * w){
            u[0][i] = abs(mp[next].first - mp[i].first) + abs(mp[next].second - mp[i].second);
        }
    }
    rep(i, 1, 20){
        rep(j, 0, h * w){
            if(j + d * (1LL << (i - 1)) < h * w){
            u[i][j] = u[i - 1][j] + u[i - 1][j + d * (1LL << (i - 1))];
            }
        }
    }
    int q;
    cin >> q;
    rep(i, 0, q){
        int l, r;
        cin >> l >> r;
        l--; r--;
        if(l == r){
            cout << 0 << endl;
            continue;
        }
        int diff = (r - l) / d;
        int ans = 0;
        int now = l;
        repb(j, 19, 0){
            if(diff & (1LL << j)){
                ans += u[j][now];
                now = now + d * (1LL << j);
            }
        }
        cout << ans << endl;
    }
}

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

using ll = long long; using vi = vector<int>; using vll = vector<ll>;
using vvi = vector<vi>; using vvll = vector<vll>;
const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll INF_MAX = numeric_limits<ll>::max();

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

  int n, m;
  cin >> n >> m;

  vvi df(m, vi(3));
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> df[i][j];
    }
  }
  sort(df.begin(), df.end());

  map<int, ll> shortest;
  shortest[1] = 0;
  shortest[n] = INF_MAX;

  for (auto row : df) {
    int left = row[0];
    int right = row[1];
    int distance = row[2];
    auto begin = shortest.lower_bound(left);
    auto last = shortest.lower_bound(right);

    if (begin->second == INF_MAX) continue;
    ll length = begin->second + static_cast<ll>(distance);
    if (length >= last->second) continue;
    shortest[right] = length;

    while (begin != last) {
      if (length < begin->second) {
        begin = shortest.erase(begin);
      } else {
        begin++;
      }
    }
  }

  if (shortest[n] == INF_MAX) {
    cout << -1 << endl;
  } else {
    cout << shortest[n] << endl;
  }
}


Measured memory_bytes: 11776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main(void){
  std::string str;
  std::cin >> str;

  int n = 0, w = 0, s = 0, e = 0;

  for (int i=0; i<str.size(); i++) {
    if (str[i] == 'N')
      n++;
    else if (str[i] == 'W')
      w++;
    else if (str[i] == 'S')
      s++;
    else if (str[i] == 'E')
      e++;
  }

  if (n*1000 >= s && n <= s*1000) {
    if (w*1000 >= e && w <= e*1000) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  } 
  
  std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

red = [0]*N
red[0] = 1

q = [1]*N

for _ in range(M):
    x, y = map(int, input().split())
    red[y-1] |= red[x-1]
    q[x-1] -= 1
    q[y-1] += 1
    if q[x-1] == 0:
        red[x-1] = 0

print(sum([1 for i in range(N) if q[i]>0 and red[i]]))

Measured memory_bytes: 11092
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		String result = "No";
		if(s.contains("a") && s.contains("b") && s.contains("c")) result = "Yes";
		
		// 出力
		System.out.println(result);
		
	}

}




Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#define MAX 10000
#define INFTY 1<<30 // 2^30
using namespace std;
typedef long long llong;
static const int NIL = -1;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra()
{
  priority_queue<pair<int, int> > PQ;
  int color[MAX];
  int d[MAX];
  for(int i = 0; i < n; i++)
  {
    d[i] = INFTY;
    color[i] = WHITE;
  }
  d[0] = 0;
  PQ.push(make_pair(0,0));
  while(!PQ.empty())
  {
    pair<int, int> f = PQ.top(); PQ.pop();
    int u = f.second;
    color[u] = BLACK;
    if(d[u] < f.first * (-1)) continue;
    for(int j = 0; j < adj[u].size(); j++)
    {
      int v = adj[u][j].first;
      if(color[v] == BLACK) continue;
      if(d[v] > d[u] + adj[u][j].second)
      {
        d[v] = d[u] + adj[u][j].second;
        PQ.push(make_pair(d[v] * (-1),v));
        color[v] = GRAY;
      }
    }
  }
  for(int i = 0; i < n; i++)
    cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
}

int main()
{
  cin >> n;
  int k, c, u, v;
  for(int i = 0; i < n; i++)
  {
    cin >> u >> k;
    for(int j = 0; j < k; j++)
    {
      cin >> v >> c;
      adj[u].push_back(make_pair(v, c));
    }
  }
  dijkstra();
  return 0;
}

Measured memory_bytes: 6308
#include <stdio.h>

int main(void)
{
    int pack[3];
    scanf("%d%d%d", &pack[0], &pack[1], &pack[2]);

    if (pack[0] == pack[1] + pack[2] || pack[1] == pack[0] + pack[2] || pack[2] == pack[1] + pack[0]) printf("Yes\n");
    else printf("No\n");

    return (0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int N,posn = 0,negn = 0;
    ll ans = 0;
    cin>>N;
    vll A(N);
    rep(i,N)
    {
        cin>>A[i];
        if(A[i]>0)
        {
            posn++;
        }
        else if(A[i]<0)
        {
            negn++;
        }
    }
    if(negn % 2 == 0)
    {
        rep(i,N)
        {
            ans += abs(A[i]);
        }
    }
    else {
        rep(i,N)
        {
            A[i] = abs(A[i]);
        }
        sort(all(A));
        rep(i,N-1)
        {
            ans += abs(A[i+1]);
        }
        ans -= A[0];
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 1024
use std::error::Error;
use std::io;

fn lcm (x: u64, y: u64) -> u64 {
    return x / gcd(x, y) * y;
}

fn gcd (x: u64, y: u64) -> u64 {
    if y == 0 {
        return x;
    }
    return gcd(y, x % y);
}

fn main() {
    if let Err(e) = run() {
        println!("{}", e);
    }
}

fn run() -> Result<(), Box<Error>> {
    let mut n = String::new();
    io::stdin().read_line(&mut n)?;
    let n: usize = n.trim().parse()?;
    let mut t: Vec<u64> = Vec::with_capacity(n);
    for _ in 0..n {
        let mut s = String::new();
        io::stdin().read_line(&mut s)?;
        t.push(s.trim().parse()?);
    }
    let mut ans: u64 = 1;
    for i in 0..n {
        ans = lcm(ans, t[i]);
    }
    println!("{}", ans);
    Ok(())
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N-2+1);
    for(int i = 0 ; i < N-2+1 ; i++){
        scanf("%lld",&A[i]);
    }
    //solve(N, std::move(A));
    map<ll,ll> m;
    for (long long i = 1; i <= N; i++) {
        m[i]=0;
    }
    for (long long i = 0; i < N-1; i++) {
        m[A[i]]++;
    }
    for (auto& e: m) {
        cout << e.second << endl;
    }
    return 0;
}


Measured memory_bytes: 17260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=3e3+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll dp[MAXn][MAXn];
ll sum[MAXn][MAXn];
ll add(ll a,ll b){
  return (a+b)%MOD;
}
ll sub(ll a,ll b){
  return (a-b+MOD)%MOD;
}
int main(){
  IOS();
  ll n;
  string s;
  cin >> n >> s;
  dp[1][1] = sum[1][1] = 1;
  for (ll i=2;i<=n;i++) {
    REP1 (j,i) {
      if (s[i-2] == '<') dp[i][j] = sum[i-1][j-1];
      else dp[i][j] = sub(sum[i-1][i-1],sum[i-1][j-1]);
    }
    REP1 (j,n) sum[i][j] = add(sum[i][j-1],dp[i][j]);
    pary(sum[i],sum[i]+n);
  }
  cout << sum[n][n] << endl;
}


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

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a.at(i);
  }

  int b = 0;
  for (int i = 0; i < n - 1; i++) {
    b = a.at(b) - 1;
    if (b == 1) {
      std::cout << i + 1 << '\n';
      return 0;
    }
  }
  std::cout << -1 << '\n';
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string p, q;
    REP(i, n) {
        string a;
        cin >> a;
        p += a;
    }
    REP(i, n) {
        string a;
        cin >> a;
        q += a;
    }
    int P = stoi(p), Q = stoi(q);
    vi v;
    REP(i, n) v.push_back(i + 1);
    int p_num = 0, q_num = 0;
    do {
        int val = 0;
        for(int i = n - 1; i >= 0; --i) {
            val += v[i] * pow(10, i);
        }
        if(P >= val) p_num++;
        if(Q >= val) q_num++;
    } while(next_permutation(v.begin(), v.end()));

    cout << abs(p_num - q_num) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n; cin>>n;
string s; cin>>s;
ll ca=0;
rep(i,n){
if(s.at(i)=='R'){
ca++;}}
if(ca>n-ca){
cout << "Yes" << endl;}
else{
cout << "No" << endl;}}


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

using namespace std;

inline void chmin(int &a, int b) { a = min(a, b); }

int N, M;
int sum[20][100001];
int dp[1 << 20];

int main()
{
  scanf("%d %d", &N, &M);
  for(int i = 0; i < N; i++) {
    int K;
    scanf("%d", &K);
    sum[--K][i + 1]++;
    for(int j = 0; j < 20; j++) {
      sum[j][i + 1] += sum[j][i];
    }
  }

  memset(dp, 0x3f, sizeof(dp));
  dp[0] = 0;
  for(int i = 0; i < (1 << M); i++) {
    int left = 0;
    for(int j = 0; j < M; j++) {
      if((i >> j) & 1) left += sum[j][N];
    }
    for(int j = 0; j < M; j++) {
      if((i >> j) & 1) continue;
      chmin(dp[i | (1 << j)], dp[i] + sum[j][N] - sum[j][left + sum[j][N]] + sum[j][left]);
    }
  }

  printf("%d\n", dp[(1 << M) - 1]);
}

Measured memory_bytes: 15096
#include<bits/stdc++.h>
using namespace std;
struct rule{
  string a;
  string b;
  string c;
};
int main(){
  while(1){
    
    int n,m;
    cin >> n >> m;
    if(n==0&&m==0)break;
    rule r[1100];
    rule p[1100];
    vector<int> ok(m,0);
    for(int i=0;i<n;i++){
      cin >> r[i].a >>r[i].b >> r[i].c;
    }
    for(int i=0;i<m;i++){
      cin >> p[i].a >>p[i].b >> p[i].c;
    }
    int f=0;
    for(int i=0;i<n;i++){
      if(r[i].a[0]=='p'){
	f=1;
      }
      else f=0;
    
      //cout << f << endl;
      for(int j=0;j<m;j++){
	int fl=0;
	//cout << r[i].b << " "<<p[j].c<< endl;
	for(int k=0;k<r[i].b.size();k++){
	  if(r[i].b[k]!='?'&&r[i].b[k]!=p[j].a[k]){
	    fl=1;
	    break;
	  }
	  if(r[i].c[k]!='?'&&r[i].c[k]!=p[j].b[k]){
	    fl=1;
	    break;
	  }
	}
	if(fl==0){
	  ok[j]=f;
	}
      }
    }
    int co=0;
    for(int i=0;i<m;i++){
      if(ok[i]==1)co++;
      // cout << ok[i] << endl;
    }
    cout << co << endl;  
    for(int i=0;i<m;i++){
      if(ok[i]==1)cout <<p[i].a << " "<< p[i].b << " "<< p[i].c<< endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3364
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = LLONG_MAX, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
    cin >> A >> B;
    if(A == B) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include<iostream> //cinなど
#include<string> //文字列
#include<algorithm> //sort など
#include<math.h> //paw(冪乗など)
#include<set> // 集合
#include<map> //写像
#include<stdio.h> //printf
#include<stack>

using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if((a<=c) && (b>=c)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define all(x) x.begin(),x.end() 
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define per(i,a,b) for(ri i=(a);i>=(b);--i)
#define ls (x<<1)
#define rs (x<<1|1)
#define mid (l+r>>1)
#define de(x) cout << #x << " = " << x << endl
#define dd() cout << "Out Put!\n"
const int mod= 1e9+7,maxn=1000010;
const double eps = 1e-8,PI = acos(-1.0);
const int inf=0x7f7f7f7f;
using namespace std;
int a[maxn],b[maxn],v[maxn];
string s;
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		cout << (1000-n%1000)%1000 <<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

const ll MOD = 1e9+7;

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

  ll N;
  cin >> N;
  vector<ll> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }

  vector<ll> cnt_base(60);
  for(ll i = 0; i < 60; i++){
    cnt_base[i] = 0;
  }

  for(ll i = 0; i < 60; i++){
    ll base = (1LL << i);
    
    for(ll j = 0; j < N; j++){
      if(A[j] & (1LL << i)){
        cnt_base[i]++;
      }
    }
  }

  ll tmp_ans = 0;
  for(int i = 0; i < N; i++){
    ll base = 1;
    for(int j = 0; j < 60; j++){
      if(A[i] & (1LL << j)){
        tmp_ans = (tmp_ans + base * (N - cnt_base[j])) % MOD;
      }else{
        tmp_ans = (tmp_ans + base * cnt_base[j]) % MOD;
      }
      base = (base * 2) % MOD;
    }
  }

  ll ans = (tmp_ans * modinv(2, MOD)) % MOD;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
 
using namespace std ; 
 
const int N = 1e6 +  7 ; 
 
long long  n ; 
 
long long f(int x){
    long long ret = n/x ; 
    return x * ret*(ret+1) /2 ; 
}
 
int main(){
    ios_base::sync_with_stdio(0) ; 
    cin.tie(0) ; 
   // freopen("in.in" , "r" , stdin) ; 
    cin>> n ;
    cout<<n*(n+1) /2 -f(3) -f(5) + f(15) ;
    return 0 ; 
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    int n, m;
    bool flag;
    cin >> n >> m;
    vector<string> a(n), b(m);
    for (int i = 0; i < n; ++i) cin >> a.at(i);
    for (int i = 0; i < m; ++i) cin >> b.at(i);
    for (int i = 0; i < n - m + 1; ++i) {
        for (int j = 0; j < n - m + 1; ++j) {
            flag = true;
            for (int di = 0; di < m; ++di) for (int dj = 0; dj < m; ++dj) flag &= b.at(di).at(dj) == a.at(i + di).at(j + dj);
            if (flag) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var l1 = ReadLongArray();

        long N = l1[0];
        long K = l1[1];

        var result = 0;
        while(N>0)
        {
            N /= K;
            result++;

        }
        Console.WriteLine(result);
    }

    static string[] ReadStringArray()
    {
        return Console.ReadLine().Trim().Split(' ');
    }

    static int[] ReadIntArray()
    {
        return ReadStringArray().Select(_ => int.Parse(_)).ToArray();
    }

    static long[] ReadLongArray()
    {
        return ReadStringArray().Select(_ => long.Parse(_)).ToArray();
    }
}
 


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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

const int MX = 30000;
ll dp[MX];

int main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    for (int i=0; i<N; ++i) {
        cin >> A[i] >> B[i];
    }

    for (int i=0; i<MX; ++i) {
        dp[i] = MX*MX;
    }
    dp[0] = 0;
    for (int i=0; i<N; ++i) {
        for (int j=0; j<MX; ++j) {
            if (j+A[i] < MX) {
                dp[j+A[i]] = min(dp[j+A[i]], dp[j]+B[i]);
            }
        }
    }

    ll ans = LLONG_MAX;
    for (int i=H; i<MX; ++i) {
        ans = min(ans, dp[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
N = int(input())
A = []
B = []

for i in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)


c = 0

A = A[::-1]
B = B[::-1]

# print(A)
# print(B)

for i in range(N):
    ai = A[i] + c
    if ai % B[i] == 0:
        pass
    else:
        tmp = B[i] - (ai % B[i])
        c += tmp

print(c)


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

using namespace std;

#define ll long long
#define MoD 1e9 + 7
#define clear(a) memset(a, 0, sizeof(a))
#define fo(i, a, b) for(int i = a; i < b; i++)
//#define re(i, a, b) for(int i = b; i > a; i--)
#define pb(a) push_back(a)

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

string n;
void solve(){
	cin >> n;

	int ans=0;
	fo(i, 0, n.length())ans+=n[i]-'0';
	string yy= (ans%9==0)?"Yes":"No";
	cout << yy << '\n';
}

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

	int t=1;
	for(int i=1; i<=t; ++i) {
		solve();
	}

}


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

using namespace std;

using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 1e6 + 5, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18, MOD = 1e15 + 37;
const ld PI = acos(-1);

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(13) << fixed;

    //////////////////////////////////////////
    //////////////////////////////////////////

    int x, y;
    cin >> x >> y;
    for (int a = 0; a <= x; ++a) {
        if (4 * a + (x - a) * 2 == y) {
            cout << "Yes\n";
            return 0;
        }
    }

    cout << "No\n";
}


Measured memory_bytes: 3644
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
 
using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
 

int main(){

    int a,b;
    cin >> a >> b;
    int res;
    
    res = 6-a-b;
    cout << res <<endl;

} 
 
 
 

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC128
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine().Split(' ');
			var A = int.Parse(input[0]);
			var P = int.Parse(input[1]);

			Console.WriteLine((A * 3 + P) / 2);
		}
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)

int main(){
    vector<vector<int>> c(3,vector<int>(3));
    rep(i, 0, 3) rep(j, 0, 3) cin >> c[i][j];
   
    int d1 = c[0][0] - c[0][1], d2 = c[0][1] - c[0][2];
    int d3 = c[1][0] - c[1][1], d4 = c[1][1] - c[1][2];
    int d5 = c[2][0] - c[2][1], d6 = c[2][1] - c[2][2];

    if(d1 == d3 && d3 == d5 && d2 == d4 && d4 == d6)
    cout << "Yes" << endl;
    else 
    cout << "No" << endl;

}

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

#define N 30
#define W 2000

int n;
int a[N];
bool dp[N][W];
bool dpt[N][W];

bool solve(int, int);

int main(void) {
	int q;
	int p;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < W; j++) {
			dpt[i][j] = false;
		}
	}
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	cin >> q;
	while (q--) {
		cin >> p;
		if (solve(0, p))cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

bool solve(int i, int m) {
	if (dpt[i][m]) return dp[i][m];
	if (m == 0) {
		dpt[i][m] = true;
		dp[i][m] = true;
		return true;
	}
	else if (i >= n) {
		dpt[i][m] = true;
		return dp[i][m] = false;
	}
	else if (solve(i + 1, m)) {
		dpt[i][m] = true;
		return dp[i][m] = true;
	}
	else if (solve(i + 1, m - a[i])){
		dpt[i][m] = true;
		return dp[i][m] = true;
	}
	else {
		dpt[i][m] = true;
		return false;
	}
}

Measured memory_bytes: 1256
#include <cstdio>
#include <vector>
#include <algorithm>

#define all(v) (v).begin(), (v).end()
using namespace std;

int main()
{
    int n;
    scanf("%d", &n);

    if(n == 0)
    {
        printf("0\n");
        return 0;
    }

    vector <int> A;
    while(n != 0)
    {
        if(abs(n)%(-2) == 0)
        {
            A.push_back(0);
            n /= (-2);
        }
        else
        {
            A.push_back(1);
            n = (n - 1)/(-2);
        }
    }

    reverse(all(A));

    for(int i = 0; i < A.size(); i++)
        printf("%d", A[i]);

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 998244353

int N, dp[334][90900], dp2[334][90900], a[334];
int sigma;

int modpow(int x, int y){
    if(y == 0)return 1;
    if(y % 2 == 0){
        int tmp = modpow(x, y / 2);
        return tmp * tmp % mod;
    }
    else {
        return modpow(x, y - 1) * x % mod;
    }
}

signed main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        sigma += a[i];
    }
    dp[0][0] = 1;
    dp2[0][0] = 1;
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= sigma; j++){
            if(j - a[i] >= 0){
                (dp[i + 1][j] += dp[i][j - a[i]]) %= mod;
                (dp2[i + 1][j] += dp2[i][j - a[i]]) %= mod;

            }
            (dp[i + 1][j] += dp[i][j] * 2ll % mod) %= mod;
            (dp2[i + 1][j] += dp2[i][j] % mod) %= mod;

        }
    }
    int ans = modpow(3, N);
    for(int i = (sigma + 1) / 2; i <= sigma; i++){
        ans = (ans - dp[N][i] * 3ll + 3ll * mod) % mod;
    }
    if(sigma % 2 == 0)cout << (ans + dp2[N][sigma / 2] * 3ll) % mod << endl;
    else cout << ans << endl;



    

    return 0;
}
/*



*/

Measured memory_bytes: 431616
use std::cmp::*;

// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let l_r: Vec<u64> = read_vec();
    let l = l_r[0];
    let r = l_r[1];

    // 調査A
    // lが0: 当然0が最小
    if l == 0 { println!("0"); return; }

    // 調査B
    // r - l == 1: その数同士の積しか数えられない
    if r - l == 1 { println!("{}", (r*l) % 2019); return; }

    // 調査C
    // l or rが673の倍数: 2019で割り切れるi, jの組み合わせが存在し、答えは0
    // 調査Bにおいて、673-674のような割り切れない組み合わせが除外されるため
    if l % 673 == 0 || r % 673 == 0 { println!("0"); return; }

    // 調査D
    // 2019 = 3 * 673
    // l / 673の整数部分とr / 673の整数部分が異なる
    if (l / 673) as u64 != (r / 673) as u64 {
        // 間に673の倍数が存在する
        // さらに、3の倍数が存在すれば2019で割り切れるi, jの組み合わせが存在し、答えは0
        if (l / 3) as u64 != (r / 3) as u64 {
            println!("0");
            return;
        }
    }

    // 調査E
    // ここまでに引っかからない場合は0にはできないので、最小の余りを求める
    let mut min_mod_result: u64 = 2018;
    for i in l..(r + 1)
    {
        for j in (i + 1)..(r + 1)
        {
            min_mod_result = min(min_mod_result, i*j%2019);
        }
    }

    println!("{}", min_mod_result);
}


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

int main()
{
    int R;
    cin >> R;

    if (R < 1200)
    {
        cout << "ABC";
    }
    else if (R < 2800)
    {
        cout << "ARC";
    }
    else
    {
        cout << "AGC";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.chomp("").to_i

v = gets.split(" ").map(&:to_i)

sum = 0
v.sort!
(n-1).times do |i|
  if i == 0
    sum += Rational(v[i]+v[i+1], 2)
  else
    sum = Rational(sum+v[i+1], 2)
  end
end

puts sum.to_f


Measured memory_bytes: 1788
n,*a=$<.read.split.map &:to_i
r=2
h={}
a.sort!
a.each{|e|h[e]=1}
n.times{|i|(i+1...n).each{|j|d=a[j]-a[i];r=[r,(2..1/0.0).find{|k|!h[a[i]+d*k]}].max}}
p r


Measured memory_bytes: 7396
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()

if s == 'A':
  a = 'T'
  
if s == 'T':
  a = 'A'
  
if s == 'G':
  a = 'C'
  
if s == 'C':
  a = 'G'

print(a)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a[3];
  rep(i, 3) cin >> a[i];
  sort(a, a+3);
  if (a[0] == a[1])
    cout << a[2] << endl;
  else
    cout << a[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxm=1e5+5;



signed main(){
    int a,b;cin>>a>>b;
    map<int,int>mark;
    for(int i=2;i*i<=a;i++){
        if(a%i==0){
            mark[i]=1;
            while(a%i==0)a/=i;
        }
    }
    if(a!=1)mark[a]=1;
    //
    int ans=0;
    for(int i=2;i*i<=b;i++){
        if(b%i==0){
            if(mark[i])ans++;
            while(b%i==0)b/=i;
        }
    }
    if(b!=1){
        if(mark[b])ans++;
    }
    //
    ans++;
    cout<<ans<<endl;
    return 0;
}
/*


*/


Measured memory_bytes: 3580
#include "bits/stdc++.h"
using namespace std;

#define OUT(x)  cerr << #x << " = " << x << endl;
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define piii    pair<int, pair<int, int>>
                                   
int main() {
        int i, j;
        int h, w, n;
        cin >> h >> w >> n;
        vector<int> a(n + 1);
        for (i = 1; i <= n; i ++) cin >> a[i];
        int xp = 0, yp = 0; 
        vector<vector<int> > ans(h, vector<int> (w));
        for (i = 1; i <= n; i ++) {
                for (j = 0; j < a[i]; j ++) {
                        ans[yp][xp] = i;
                        if (yp & 1) {
                                if (xp - 1 >= 0) xp --;
                                else yp ++;
                        } else {
                                if (xp + 1 < w) xp ++;
                                else yp ++;
                        }
                }
        }
        for (i = 0; i < h; i ++) for (j = 0; j < w; j ++) {
                cout << ans[i][j] << (j == w - 1 ?  '\n' : ' ');
        }
        return 0;
}



Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
struct edge{int u,v,cost;};
int parent[100];
int rank[100];

void init(int n)
{
	for(int i = 0; i < n; ++i)
	{
		parent[i]=i;
		rank[i]=0;
	}
}

int find(int x)
{
	if(parent[x]==x) return x;
	else return parent[x]=find(parent[x]);
}

void unit(int x,int y)
{
	x=find(x);
	y=find(y);
	if(x==y) return;

	if(rank[x]<rank[y])
	{
		parent[x]=y;
	}
	else
	{
		parent[y]=x;
		if(rank[x]==rank[y]) rank[x]++;
	}
}

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

bool comp(const edge& e1, const edge& e2)
{
	return e1.cost<e2.cost;
}

int main()
{
	int n;
	while(cin>>n,n)
	{
		init(n);
		int m; cin>>m;
		edge es[m];
		for(int i = 0; i < m; ++i)
		{
			scanf("%d,%d,%d",&es[i].u,&es[i].v,&es[i].cost);
		}

		sort(es,es+m,comp);
		int ans=0;
		for(int i = 0; i < m; ++i)
		{
			edge e=es[i];
			if(!same(e.u,e.v))
			{
				unit(e.u,e.v);
				ans+=e.cost-100;
			}
		}
		cout<<ans/100<<endl;
	}
  return 0;
}

Measured memory_bytes: 1320
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int Q;
  cin >> Q;
  for(int i=0; i<Q; i++){
    ll A, B;
    cin >> A >> B;
    if(A > B){
      ll tmp = A;
      A = B;
      B = tmp;
    }
    if(A == B)
      cout << 2 * A - 2 << endl;
    else if(A + 1 == B)
      cout << 2 * A - 2 << endl;
    else{
      // ll C = floor(sqrt(A * B - 1));                                                                         
      ll C = sqrt(A * B);
      if(C * C == A * B) C--;
      if(C * (C + 1) >= A * B)
        cout << 2 * C - 2 << endl;
      else
        cout << 2 * C - 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
# 要素であるかの確認は配列じゃなくsetを使う
# setはハッシュで実装されているため

N = int(input())
s = set()
 
for i in range(N):
    a=int(input())
    if a in s:
        s.remove(a)
    else:
        s.add(a)
 
print(len(s))

Measured memory_bytes: 11884
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)
# 切り上げ割り算
# -(-4 // 3)
# lis_of_lis = [[] for _ in range(N)]


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N, K = zz()
A = zz()
max_a = max(A)
rest = K
# 答えはX以下か？を考える
# 長さaの丸太を切ってX以下にするためには、
# -(-a//X)回切る必要がある


def trial(x):
    # print('try', x)
    num_cut = 0
    for a in A:
        num_cut += (-(-a//x)-1)
        # print('num_cut', num_cut)
        if (num_cut > K):
            return False
    return True


# 答えの範囲は0~max(A)
l = 0
r = max_a
while (r - l > 1):
    ans = (l + r) // 2
    if (trial(ans)):
        # print(ans)
        r = ans
    else:
        l = ans
print(r)


Measured memory_bytes: 64808
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 200000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int a[maxn+5];
int n,k; 

bool check(int x)
{
    int c=0;
    rep(i,1,n) c+=(a[i]+x-1)/x-1;
    return c<=k;
}

int lb(int l,int r)
{
    while(l<r)
    {
        int mid=(l+r)>>1;
        if(check(mid)) r=mid;
        else l=mid+1;
    }
    return r;
}

int main()
{
    scanf("%d%d",&n,&k);
    rep(i,1,n) scanf("%d",&a[i]);
    printf("%d\n",lb(1,1000000000));
    return 0;
}

Measured memory_bytes: 4536
#include <stdio.h>

void insertionSort(int s[],int N){
    int i,j;
    int v;
    for(i=1;i<N;i++){
        for(j=i-1;j>=0;j--){
            if(s[j]>s[j+1]){
                v=s[j];
                s[j]=s[j+1];
                s[j+1]=v;
            }else break;
        }
        
        for(j=0;j<N;j++){
            if(j==0)printf("%d",s[j]);
            else printf(" %d",s[j]);
        }
        printf("\n");
    }
    
}
int main(void){
    int i;
    
    int N;
    scanf("%d",&N);
    
    int s[N];
    for(i=0;i<N;i++)scanf("%d",&s[i]);
    printf("%d",s[0]);
    for(i=1;i<N;i++)printf(" %d",s[i]);
    printf("\n");
    
    insertionSort(s,N);
}


Measured memory_bytes: 2056
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long int n,a[50005],b[50005],c[100005]={0},x,count=0,count1=0,t1=0,t=0,num=1,i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		if(i%2==0)
		{
			b[count]=x;
			count++;
		}
		else
		{
			a[count1]=x;
			count1++;
		}
	}
	sort(a,a+count1);
	sort(b,b+count);
	for(i=0;i<count1;i++)
	{
		c[a[i]]++;
	}
	for(i=0;i<count-1;i++)
	{
		if(b[i]==b[i+1])
		{
			num++;
		} 
		else
		{
			if(c[b[i]]<num)
			{
				c[b[i]]=num;
			}
			num=1;
		}
	}
	if(c[b[count-1]]<num)
	{
		c[b[count-1]]=num;
	}
	sort(c,c+100005);
	cout<<(n-c[100003]-c[100004])<<endl;
}

Measured memory_bytes: 1792
// #pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
// #pragma endregion head

// #pragma region library
    
// #pragma endregion library

int main(){
    // vscode-fold=1
    string s; cin >> s;
    bool flag = false;
    rep(i,3) if (s[i]=='7') flag = true;
    if(flag) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    
}

Measured memory_bytes: 3568
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		char[] chr = null;
		
		if(str != null && str.length() < 1200) {
			chr = str.toCharArray();
			for (int i = 0; i < chr.length; i++) {
				chr[i] = getReverseCase(chr[i]);
			}
		}
		
		System.out.println(String.valueOf(chr));
	}
	
	public static char getReverseCase(char c) {
		String str = String.valueOf(c);
		if (str.equals(str.toUpperCase())) return str.toLowerCase().toCharArray()[0];
		if (str.equals(str.toLowerCase())) return str.toUpperCase().toCharArray()[0];
		return c;
	}
}

Measured memory_bytes: 24684
N,K = map(int,input().split())
X = list(map(int,input().split()))

ans = 10**9
for i in range(N-K+1):
    xl = X[i]
    xr = X[i+K-1]
    if xl*xr < 0: tmp = min(abs(xl),abs(xr))*2 + max(abs(xl),abs(xr))
    elif xr <= 0: tmp = abs(xl)
    else: tmp = xr
    if tmp < ans: ans = tmp
print(ans)

Measured memory_bytes: 14224
// AOJ 0325: Cuboid
// 2017.10.27 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct { int h, w; } T;
T tbl[6];

int cmp(T *a, T *b) { if (a->h - b->h) return a->h - b->h; return a->w - b->w; }

int main()
{
	int h, w, i, ans;

	for (i = 0; i < 6; i++) {
		scanf("%d%d", &h, &w);
		if (h < w) tbl[i].h = h, tbl[i].w = w;
		else       tbl[i].h = w, tbl[i].w = h;
	}
	qsort(tbl, 6, sizeof(T), cmp);

	ans = 1;
	for (i = 0; i < 6; i+=2)
		if (tbl[i].h != tbl[i+1].h || tbl[i].w != tbl[i+1].w) { ans = 0; break; }
	if (ans) ans = tbl[0].h == tbl[2].h && tbl[0].w == tbl[4].h && tbl[2].w == tbl[4].w;
	puts(ans ? "yes" : "no");
	return 0;
}

Measured memory_bytes: 1812
#include<bits/stdc++.h>
using namespace std;
static const int INFTY = (1 << 21);
int main(){
    string S;
    cin >> S;
    int a = INFTY, z = 0;
    for(int i = 0; i < S.size(); i++){
        if(S.at(i) == 'A'){
            a = min(a, i);
        }
        if(S.at(i) == 'Z'){
            z = max(z, i);
        }
    }
    cout << z - a + 1 << endl;
    return 0;
}

Measured memory_bytes: 3768
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);

	//0207
	static class Block{
		void print_answer() {
			for(;;) {
				int w = sc.nextInt(), h = sc.nextInt();
				if(w == 0 && h == 0) break;
				// fieldと座標を合わせるための-1
				int xs = sc.nextInt()-1, ys = sc.nextInt()-1,
					xg = sc.nextInt()-1, yg = sc.nextInt()-1;
				int n = sc.nextInt();

				int[][] field = new int[h][w];
				for(int i=0; i<n; i++) {
					int[] block = new int[4];
					for(int j=0; j<4; j++) {block[j] = sc.nextInt();}
					if(block[1] == 0) {
						for(int j=0; j<2; j++) {
							for(int k=0; k<4; k++) {
								field[block[3]-1 + j][block[2]-1 + k] = block[0];
							}
						}
					}else if(block[1] == 1) {
						for(int j=0; j<4; j++) {
							for(int k=0; k<2; k++) {
								field[block[3]-1 + j][block[2]-1 + k] = block[0];
							}
						}
					}
				}

				Queue<Point> que = new LinkedList<Point>();
				Point start = new Point(ys, xs);
				Point goal = new Point(yg, xg);
				que.offer(start);

				int[] dir_y = {-1, 0, 1, 0};
				int[] dir_x = { 0, 1, 0,-1};
				boolean ans = false;
				int mark = field[start.y][start.x];
				while(!que.isEmpty()) {
					Point point = que.poll();
					if(point.y == goal.y && point.x == goal.x) {
						ans = true;
						break;
					}
					for(int i=0; i<4; i++) {
						int ny = point.y + dir_y[i], nx = point.x + dir_x[i];
						if(ny >= 0 && nx >= 0 && ny < h && nx < w) {
							if(field[ny][nx] == mark && field[ny][nx] != 0) {
								que.offer(new Point(ny, nx));
								field[ny][nx] = -1;
							}
						}
					}
				}
				if(ans) System.out.println("OK");
				else System.out.println("NG");
			}
		}
	}

	static class Point {
		public int y, x;
		public Point(int y, int x) {
			this.y = y; this.x = x;
		}
	}

	public static void main(String[] args) {
		Block b = new Block();
		b.print_answer();
	}
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

int main()
{
	FAST_IO;

 	string a;
 	cin >> a;
 	if(a == "RRR") cout << 3 << endl;
 	else if(a[0] == 'R' && a[1] == 'R') cout << 2 << endl;
 	else if(a[1] == 'R' && a[2] == 'R') cout << 2 << endl;
 	else
 	{
 		if(a == "SSS") cout << 0 << endl;
 		else cout << 1 << endl;
 	}   
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;

int main(){
    int n;
    string s;
    cin >> n >> s;
    
    vector<int> s_inverse(2*n);
    for(int i=0; i<2*n; i++){
        if(s[i] == 'B') s_inverse[i] += 1;
        if(i % 2 == 0) s_inverse[i] += 1;
        s_inverse[i] %= 2; 
    }
    //for(int i=0; i<2*n; i++) cout << s_inverse[i];
    //cout << endl;

    long long int ans = 1;
    long long int left = 0;
    for(int i=0; i<2*n; i++){
        if(s_inverse[i] == 0) left += 1;
        if(s_inverse[i] == 1){
            ans *= left;
            ans %= MOD;
            left -= 1;
            if(left < 0){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    if(left != 0){
        cout << 0 << endl;
        return 0;
    }

    for(int i=n; i>=1; i--){
        ans *= i;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4460