akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define ll long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000001
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second
    using namespace std;
    ll mx=1000000000000000001;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T=1;
        //cin>>T;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n;
            cin>>n;
            ll a[n];
            ll pre[n+1]={0};
            for(ll i=1;i<=n;i++){
                cin>>a[i-1];
                pre[i]=pre[i-1]+a[i-1];
                //cout<<pre[i];
            }
            ll dp[n+1][n+1];
            //mem(dp,inf);
            //cout<<endl;
            for(ll l=n-1;l>=0;l--)
            {
                for(ll r=l;r<n;r++)
                {
                    if(l==r)
                        dp[l][r]=0;
                    else
                    {
                         dp[l][r]=mx;
                        for(ll i=l;i<=r-1;i++)
                        {
                           //ll sum=(pre[r]-pre[l-1]);
                           //cout<<sum<<"!!! ";
                            dp[l][r]=min(dp[l][r],dp[l][i]+dp[i+1][r]+(pre[r+1]-pre[l]));
                        }
                    }
                    //cout<<dp[l][r]<<" ";
                }
                //cout<<endl;
            }
            cout<<dp[0][n-1];
        }
        return 0;
    }


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(void) {
  int n;
  cin >> n;
  vector<int> dv;
  for(int i = 0; i < n; i++) {
    int tmp;
  	cin >> tmp;
    dv.push_back(tmp);
  }

  sort(dv.begin(), dv.end());
  
  cout << dv[n/2] - dv[n/2 - 1] << endl;
  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define pb push_back
#define lp(j, n)  for(int j=0; j<(int)(n); ++j)
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
#define F first
#define S second
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int,string> > vpii;
typedef map<int, int> mii;
const ll N=2*1e5+5;
ll arr[N],A[N]  ;
//bool visited[N]={} , cnt[N]={};
bool f=0;
int main()
{
  int n,m,count(0),ans=N;
  cin>>n;
  for(int i=0 ; i<n && cin>>m ; i++)
  {
      if(ans>=m)
      {
          ans=m;
          count++;
      }
  }
cout<<count;
 go;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

ans = 0
flag = 1
i = 1
while flag:
  y = 2**i
  m = list(map(lambda x: x%y, l))
  if 0 in m:
    ans += m.count(0)
    i += 1
  else:
    flag = 0
print(ans)

Measured memory_bytes: 4212
/*
 蟻本 例題 2-1-1　部分和問題 の類題
 ABC 104 C - All Green
 
 問題を解く組み合わせを全部調べるには時間が足りない(ノ)•̥ૅㅁ•̥(ヾ)
 そこで,
 ある難易度の問題を全問解く(or 解かない) + 解き切っていない問題で一番得点の高い問題をいくつか解く
 場合に限って調べる٩(๑❛ᴗ❛๑)۶
 */
// bit全(?)探索
let DG: [Int] = readLine()!.split(separator: " ").map { Int($0)! }
let pc: [[Int]] = (1...DG[0]).map { _ in readLine()!.split(separator: " ").map { Int($0)! }}
var res: Int = 1100 // 問題数は最大で 10 * 100 問

let w: Int = Array(repeating: 2, count: DG[0]).reduce(1, *)  // 各難易度の問題を解き切るかどうかの場合の数

for i in 0..<w {
    var num2 = String(i, radix: 2)  // 2進数へ変換
    num2 = String(repeating: "0", count: DG[0]-num2.count) + num2   // 001 みたいになるように0埋め

    var score: Int = 0
    var count: Int = 0
    var idx0: Int = 0   // 解き切ってない難易度で最大の難易度

    for (j, k) in num2.enumerated() {
        if k=="1" { // 難易度 j+1 の問題を解き切る
            score += 100*(j+1)*pc[j][0] + pc[j][1]
            count += pc[j][0]
        } else {
            idx0 = j    // 難易度 j+1 を解ききらない
        }
    }
    if score >= DG[1] { // 目標達成しているか(・・？)
        res = min(res, count)
        continue
    }
    
    // 解き切っていない難易度のうち最高難易度の問題を1問ずつ解く
    for j in 1...pc[idx0][0] {
        score += 100*(idx0+1)
        count += 1
        if j==pc[idx0][0] { score += pc[idx0][1] }  // 解き切ったとき
        if score >= DG[1] { // 目標達成しているか(・・？)
            res = min(res, count)
            break
        }
    }
}
print(res)   // (๑•ૅㅁ•๑)

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

typedef long long ll;

double Dist(vector<ll> a, vector<ll> b){
  ll sum=0;
  for(int i=0; i<a.size(); i++){
    sum += (a[i] - b[i])*(a[i] - b[i]);
  }
  return (double) sqrt(sum);
}

int main(){
  ll N,D;
  cin>>N>>D;
  vector< vector<ll> > v;
  vector<ll> buf(D);
  for(int i=0; i<N; i++){
    for(int j=0; j<D; j++){
      cin>>buf[j];
    }
    v.push_back(buf);
  }
  double dist;
  int ans=0;
  for(int i=0; i<v.size(); i++){
    for(int j=i+1; j<v.size(); j++){
      dist=Dist(v[i],v[j]);
      if(dist==floor(dist)){
        ans++;
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> blue(n);
    for (int i = 0; i < n; i++) {
        cin >> blue[i];
    }
    int m;
    cin >> m;
    vector<string> red(m);
    for (int i = 0; i < m; i++) {
        cin >> red[i];
    }

    int ans = 0;
    auto calc = [&](string s) {
        int buf = 0;
        for (string t: blue) {
            if (t == s) buf++;
        }
        for (string t: red) {
            if (t == s) buf--;
        }
        return buf;
    };

    for (string t: blue) {
        ans = max(ans, calc(t));
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
	par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
  int a,b;
  cin>>a>>b;
  cout<<(a+b)%24<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a,b;
  cin >>a>>b;
  int h=0;
  for(int i=1;i<=b-a;i++){//高いほうの本当の高さ
    h += i;
  }
  cout<<h-b<<endl;
  return 0;
    
  
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX (int)1e+5
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg
#define newl cout<<"\n"
using namespace std;
typedef long long ll;
int N,x;
int a[NMAX];
ll clac(){
  ll res=0;
  rep(i,N-1){
    int dif=a[i]+a[i+1]-x;
    if(dif>0){
      res+=dif;
      a[i+1]=max(0,a[i+1]-dif);
    }
  }
  return res;
}
int main(){
  scan(N);scan(x);
  rep(i,N) scan(a[i]);
  prin(clac());newl;
  return 0;
}


Measured memory_bytes: 640
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
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; }
typedef unsigned long ul;
typedef unsigned int ui;
const ul INF = 1LL<<60;
long N,Y,x,y,z;

inline void solve(){
  IN2(N,Y);
  REP(x,N+1)REP(y,N-x+1){
    z=N-x-y;
    if(z<0)break;
    if(10000*x+5000*y+1000*z==Y){
      OUT3(x,y,z);
      return;
    }
  }
  OUT3(-1,-1,-1);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n= sc.nextInt();
		long[] A = new long[n];
		long[] ANS = new long[n];
		ANS[n-1]=0;	

		for (int i = 0; i < n-1; i++)
			A[i]= sc.nextInt();
		
		for (int i = 0; i < n-1; i++)
			ANS[(int) (A[i]-1)]++;	

		for (int i = 0; i < n; i++) 
		System.out.println(ANS[i]);
      
		sc.close();
	}
}

Measured memory_bytes: 63460
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}

int a[200];
signed main(){
    int n;
    cin >> n;
    int ans = 0;
    REP(i,n){
        int a1;
        cin >> a1;
        if(i%2==0 && a1%2==1){
            ans ++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll  = long long;
using ii  = pair < int , int >;
using i3  = pair < int , ii >;
using vi  = vector < int >;
using vii = vector < ii >;
using vi3 = vector < i3 >;

const int N = 444;
const ll INF = 1e18;
const double eps = 1e-9 , PI = acos(-1);

int n;
ll dp[N][N];
ll a[N];

void solve(){
    scanf("%d" , &n);
    for(int i = 1 ; i <= n ; i ++){
        scanf("%lld" , &a[i]);
    }

    for(int i = 0 ; i <= n ; i ++){
        for(int j = 0 ; j <= n ; j ++){
            dp[i][j] = INF;
        }
    }

    for(int i = 1 ; i <= n ; i ++){
        dp[i][i] = 0;
    }

    for(int i = 1 ; i <= n ; i ++){
        a[i] += a[i-1];
    }

    for(int l = 2 ; l <= n ; l ++){
        for(int i = 1 ; i <= n-l+1 ; i ++){
            int j = i+l-1;
            for(int k = i ; k < j ; k ++){
                dp[i][j] = min(dp[i][j] , dp[i][k] + dp[k+1][j] + (a[k] - a[i-1]) + (a[j] - a[k]) );
            }
        }
    }

    printf("%lld\n" , dp[1][n]);
}

main(){
    int t = 1;
    //scanf("%d" , &t);

    while( t -- ){
            solve();
    }

    return 0;
}




Measured memory_bytes: 1664
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-08 20:24:14
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int A, B, m; cin >> A >> B >> m;
  vector<int64> a(A), b(B);
  cin >> a >> b;

  int64 ans = *min_element(all(a)) + *min_element(all(b));

  for (int i = 0; i < m; ++i) {
    int x, y; cin >> x >> y; --x; --y;
    int64 c; cin >> c;
    ans = min(ans, a[x] + b[y] - c);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
from functools import reduce
mod = 10**9 + 7

n = int(input())
arr = list(map(int, input().split()))
to_mutiply = [0]*n

for i in range(n-2, -1, -1):
    to_mutiply[i] = to_mutiply[i+1] + arr[i+1]

data = list(map(lambda i: (to_mutiply[i]*arr[i]) % mod, range(n-1)))
print(reduce(lambda x, y: (x+y) % mod, data))


Measured memory_bytes: 111912
#include <bits/stdc++.h>
using namespace std;
using Graph_c = vector<vector<char>>;
using ll=long long;
struct Z{
  ll y;
  ll x;
  ll depth;
};

ll H,W,y,x,depth;
vector<ll> y_vec={1,0,-1,0};
vector<ll> x_vec={0,1,0,-1};
Graph_c A,B;
queue<Z> q;

ll bfs(ll H, ll W){
  while(!q.empty()){
    Z now=q.front(); q.pop();
    y=now.y, x=now.x, depth=now.depth;
    if(y==H && x==W)
      return(depth);
    for(ll i=0; i<4; i++){
      Z next={y+y_vec[i], x+x_vec[i], depth+1};
      if(A[next.y][next.x]=='.'){
        A[next.y][next.x]='#';
        q.push(next);
      }
    }
  }
  return (-1);
}

int main() {
  int H,W;
  cin>>H >>W;
  int cnt=0;
  A.assign(H+2, vector<char>(W+2,'#'));
  for(int y=1; y<=H; y++){
    for(int x=1; x<=W; x++){
      char c;
      cin>>c;
      A[y][x]=c;
      if(c=='#')
        cnt++;
    }
  }
  ll root=H*W;
  if(A[1][1]=='#' || A[H][W]=='#'){
    cout<<-1<<endl;
    return(0);
  }
  A[1][1]='#';
  Z start={1,1,1};
  q.emplace(start);
  root=min(root,bfs(H, W));
  if(root==-1){
    cout<<-1<<endl;
    return(0);
  }    
  ll ans=H*W;
  ans-=cnt+root;
  cout<<ans<<endl;
}


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

long long int N, M, a[101010], A;
unordered_map<long long, long long> m;

int main(){
    scanf("%lld%lld", &N, &M);
    for(int i = 1; i <= N; ++i){
        scanf("%lld", a + i);
        a[i] += a[i - 1];
        a[i] %= M;
    }
    for(int i = 0; i <= N; ++i)A += m[a[i]]++;
    cout << A << endl;
    return 0;
}

Measured memory_bytes: 4492
#include <bits/stdc++.h> // Integer Product, by Errichto
using namespace std;
int main() {
    int n;
    scanf("%d", &n);
    map<pair<int,int>, int> cnt;
    for(int rep = 0; rep < n; ++rep) {
        double x;
        scanf("%lf", &x);
        long long i = llround(x * 1e9);
        int two = 0, five = 0;
        while(i % 2 == 0) {
            two++;
            i /= 2;
        }
        while(i % 5 == 0) {
            five++;
            i /= 5;
        }
        ++cnt[{two,five}];
    }
    long long answer = 0;
    for(auto p1 : cnt) {
        for(auto p2 : cnt) {
            if(p1.first.first+p2.first.first >= 18 && p1.first.second+p2.first.second >= 18) {
                if(p1 < p2) {
                    answer += (long long) p1.second * p2.second;
                }
                else if(p1 == p2) {
                    answer += (long long) p1.second * (p1.second - 1) / 2;
                }
            }
        }
    }
    printf("%lld\n", answer);
}


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

int main(void){
    
    ll n, k, a[200009]={}, tmp=1, j=0, p=0;
    ll m[200009]={};
    
    cin >> n >> k;
    
    for(ll i=1; i<=n; i++){
        
        cin >> a[i];
        
    }
    
    for(ll i=1; i<=k; i++){
        
        m[tmp] = i;
        tmp = a[tmp];
        
        if(m[tmp]>=1){
            
            i += 1;
            j = i - m[tmp];
            p = (k+1-i) % j;
            
            for(ll q=1; q<=n; q++){
                
                if(m[tmp]+p==m[q]){
                    
                    cout << q << endl;
                    return 0;
                    
                }
                
            }
            
            
        }
        
        if(i>=k){
            
            cout << tmp << endl;
            
        }
        
    }
    
    return 0;
    
}

Measured memory_bytes: 6716
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   


      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         
ll n;
cin>>n;
ll a[n];
set<ll>st;
for(int i=0;i<n;i++)
{
    cin>>a[i];
    st.insert(a[i]);
}
if(st.size()==n)
cout<<"YES\n";
else
cout<<"NO\n";
         

      }
      






}



























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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)


int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	double sum = 0;
	FOR(i, 1, n) {
		cin >> a[i-1];
		sum += a[i - 1];
	}
	double tmp = sum / n;
	int goal = floor(tmp+0.5);
	int res=0;
	FOR(i, 0, n - 1) {
		res += (a[i] - goal)*(a[i] - goal);
	}
	pv(res)
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>
#define endl "\n"
typedef long long int ll;
typedef unsigned long long int ull;
typedef float fl;
typedef short int si;
using namespace std;
void solve()
{
    int n;long long d; cin >> n >> d; d*=d;
    long long a,b,c; int ans=0;
    for (int i=0;i<n;++i){
        cin >> a >> b;
        c=a*a+b*b;
        if(d>=c) ++ans;
    }   cout << ans;
}

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


Measured memory_bytes: 3652
def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)


def lcm(a, b):
    return a * b // gcd(a, b)


N = int(input())
A = list(map(int, input().split()))

l = 0
for i in range(1, len(A)):
    l = lcm(A[i - 1], A[i])
ans = l - 1
ans = sum(A) - len(A)
print(ans)


Measured memory_bytes: 3316
//This Code was made by Chinese_zjc_.
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <time.h>
// #include<windows.h>
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
int n, q, fa[200005], a, b, c;
int find(int now)
{
    return fa[now] == now ? now : fa[now] = find(fa[now]);
}
signed main()
{
    ios::sync_with_stdio(false);
    cin >> n >> q;
    for (int i = 1; i <= n; ++i)
    {
        fa[i] = i;
    }
    for (int i = 1; i <= q; ++i)
    {
        cin >> a >> b >> c;
        if (a == 0)
        {
            fa[find(b)] = find(c);
        }
        if (a == 1)
        {
            cout << (find(b) == find(c)) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4960
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i<n; i++) {
      a[i] = sc.nextInt();
    }
    for(int i = 1;;i++) {
      if(i == n) {
        System.out.println(a[n-i]);
        return;
      }
      System.out.print(a[n-i] + " ");
    }
  }
}

Measured memory_bytes: 26244
n = int(input())
A = [int(x) for x in input().split()]
m = int(input())
B = [int(x) for x in input().split()]

ans = 0

for i in range(min(len(A), len(B))):
    if A[i] < B[i]:
        ans = 1
        break
    elif A[i] > B[i]:
        break
else:
    if len(A) < len(B):
        ans = 1

print(ans)



Measured memory_bytes: 5632
n = int(input())

list = []
for i in range(n):
  a = input()
  list.append(a)

print('AC x {}'.format(list.count('AC')))
print('WA x {}'.format(list.count('WA')))
print('TLE x {}'.format(list.count('TLE')))
print('RE x {}'.format(list.count('RE')))

Measured memory_bytes: 16152
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
	H, W, K = MAP()
	cake = [list(input()) for _ in range(H)]
	cut = [[1 for _ in range(W)] for _ in range(H)]
	lis_0 = []
	lis_1 = []
	num = 1
	for i in range(H):
		if cake[i].count("#") > 0:
			lis_1.append(i)
		else:
			lis_0.append(i)
			continue

		ct = 0
		for j in range(W):
			if cake[i][j] == "#":
				ct += 1
				if ct < 2:
					cut[i][j] = num
				else:
					num += 1
					ct = 1
					cut[i][j] = num
			else:
				cut[i][j] = num

		num +=1

	# print(lis_0)
	# print(lis_1)

	for x in lis_0:
		ind = bisect(lis_1, x)
		# print(ind)
		if ind == len(lis_1):
			ind -= 1
		cut[x] = cut[lis_1[ind]]
		# print("x", cut[x])
		# print("ind", cut[lis_1[ind]])

	for x in cut:
		print(*x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10416
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <stack>
#include <cmath>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int inf=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll a,ll b){
	return (b==0)?(a):(GCD(b,a%b));
}
ll LCM(ll a,ll b){
	return a/GCD(a,b)*b;
}
//
int main(){
	int M,F,B;
	cin>>M>>F>>B;
	if(M>=B){
		cout<<0<<endl;
	}else if(B-M<=F){
		cout<<(B-M)<<endl;
	}else{
		cout<<"NA"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <functional>
#define int long long 
#define pi pair<int,int> 
#define endl "\n"
using namespace std ;

const int inf = 1e15 ;
const int size = 1e5 + 5 ;


int32_t main() 
{


     /*#ifndef ONLINE_JUDGE 
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     #endif*/
     int n , w ;
     cin >> n >> w ;
     int a[size][2];
     for(int i = 1 ; i <= n ; i++ ) cin >> a[i][0] >> a[i][1] ;
     int dp[size] ;dp[0] = 0 ;
     for(int i = 1; i <= n ; i++ )
     {
         for(int j = w-a[i][0] ; j >= 0 ; j-- )
         {
             dp[j+a[i][0]] = max(dp[j]+a[i][1],dp[j+a[i][0]]);
         }
        
     }
     int ans = 0*1LL ;
     for(int i = 1; i <= w ; i++ )
     {
         ans = max(ans,dp[i]);
     }
     cout<<ans<<endl;
     return 0 ;
}


Measured memory_bytes: 2560
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 110, X = 510, mod = 1e9 + 7;

int add(int x, int y) {
	x += y;
	if (x >= mod) {
		x -= mod;
	}
	return x;
}

int sub(int x, int y) {
	x -= y;
	if (x < 0) {
		x += mod;
	}
	return x;
}

int mul(ll x, int y) {
	return (x * y) % mod;
}

int l[N], dp[N][N][X], pf1[N][N][X], pf2[N][N][X];

int main() {
	fast_cin();
	int n, x;
	cin >> n >> x;
	for (int i = 1; i <= n; ++i) {
		cin >> l[i];
	}
	sort(l + 1, l + 1 + n, greater<int>());
	dp[0][0][0] = 1;
	auto get = [&](int* pf, int lo, int hi) {
		if (lo > hi or hi < 0) {
			return 0;
		} else {
			return sub(pf[hi], (lo > 0 ? pf[lo - 1] : 0));
		}
	};
	for (int i = 0; i <= n; ++i) {
		for (int k = 0; k * l[i] <= x and k <= i; ++k) {
			for (int sum = 0; sum <= x and i; ++sum) {
				auto& cur = dp[i][k][sum];
				cur = mul(dp[i - 1][k][sum], sum - k * (l[i] - 1));
				if (k and sum >= l[i]) {
					cur = add(cur, dp[i - 1][k - 1][sum - l[i]]);
				}
				cur = add(cur, mul(2 * k, get(pf1[i - 1][k], sum - l[i] + 1, sum - 1)));
				int temp = get(pf2[i - 1][k + 1], sum - l[i] + 2, sum);
				temp = add(temp, mul(sub(l[i], sum + 1), get(pf1[i - 1][k + 1], sum - l[i] + 2, sum)));
				cur = add(cur, mul(temp, k * (k + 1)));
			}
			pf1[i][k][0] = dp[i][k][0];
			for (int sum = 1; sum <= x; ++sum) {
				pf1[i][k][sum] = add(pf1[i][k][sum - 1], dp[i][k][sum]);
				pf2[i][k][sum] = add(pf2[i][k][sum - 1], mul(sum, dp[i][k][sum]));
			}
		}
	}
	int ans = 0, fact = 1;
	for (int k = 1; k <= n; ++k) {
		fact = mul(fact, k);
		ans = add(ans, mul(fact, dp[n][k][x]));
	}
	cout << ans << endl;
}

Measured memory_bytes: 70144
a = int(input())

num =[]

for i in range(1, a + 1):
    if i % 3 == 0:
        num.append(i)
        
    x = str(i)
    x = list(x)

    if ("3" in x) and (i not in num):
        num.append(i)

for i in num:    
    print(f" {i}", end = "")
    
print("")


Measured memory_bytes: 6116
#include<bits/stdc++.h>
using namespace std;
map<pair<int,int>,int>a;
long long h,w,n,sum,ans[1000003],ans1[13];
int a1,b1;
int main()
{
	cin>>h>>w>>n;
	for(int k=1; k<=n; k++)
	{
		scanf("%d%d",&a1,&b1);
		for(int i=max(3,a1); i<=a1+2; i++)
			for(int j=max(b1,3); j<=b1+2; j++)
				if(i<=h&&j<=w)
				{
					if(a[make_pair(i,j)]==0)
						sum++,a[make_pair(i,j)]=sum,ans[sum]=1;
					else
						ans[a[make_pair(i,j)]]++;
				}
	}
	for(long long i=1; i<=sum; i++)
		ans1[ans[i]]++;
	ans1[0]=(h-2)*(w-2)-sum;
	for(long long i=0; i<=9; i++)
		cout<<ans1[i]<<endl;
	return 0;
}

Measured memory_bytes: 65536
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
string a[101];
bool cmp(string a,string b)
{
	return  a < b;
}
int main()
{
	
	int n,l;
	cin>>n>>l;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n,cmp);
	for(int i=0;i<n;i++)
		cout<<a[i];
	return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

string nxt(string s) {
    int ma = -1;
    for (int i = 1; i < s.length(); i++) {
        string s1 = s.substr(0, i);
        string s2 = s.substr(i);
        int mul = stoi(s1) * stoi(s2);
        ma = max(ma, mul);
    }
    return to_string(ma);
}

int solve(string s) {
    int cnt = 0;
    set<string> his;
    while (s.length() > 1) {
        cnt++;
        his.insert(s);
        s = nxt(s);
        if (his.count(s)) return -1;
    }
    return cnt;
}

int main() {
    int Q; cin >> Q;
    while (Q--) {
        string N; cin >> N;
        cout << solve(N) << endl;
    }
    return 0;
}


Measured memory_bytes: 3284
<?php

while (true) {
    $answer = 0;
    $memo = [];
    $nums = explode(" ", trim(fgets(STDIN)));
    $max = $nums[0];
    $target = $nums[1];
    if ($max == 0 && $target == 0) break;

    for ($i = 1; $i <= $max; $i++) {
        for ($j = 1; $j <= $max; $j++) {
            for ($k = 1; $k <= $max; $k++) {
                if ($i + $j + $k == $target && !($i == $j || $j == $k || $i == $k)) {
                    $tmp = [$i, $j, $k];
                    sort($tmp);
                    if (in_array($tmp, $memo) === false) {
                        $memo[] = $tmp;
                        $answer++;
                    }
                }
            }
        }
    }
    echo $answer . "\n";
}


Measured memory_bytes: 10172
import { readFileSync } from "fs";
const input = readFileSync("/dev/stdin", "utf8");

const [NK, HS] = input.split("\n");

let [N, K] = NK.split(" ").map(s => ~~s);
const H = HS.split(" ")
    .map(x => ~~x)
    .sort((a, b) => b - a);

let count = 0;

H.splice(0, K);

H.forEach(h => {
    count = count + h;
});

console.log(count);


Measured memory_bytes: 37148
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect

setrecursionlimit(10**7)

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N = read()
A = [0] * N
B = [0] * N

for i in range(N):
  A[i], B[i] = reads()

ans = sum(A)
C = [A[i] + B[i] for i in range(N)]
C.sort()
C.reverse()

for i in range(1, N, 2):
  ans -= C[i]

print(ans)

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    int ans = 1, h = 0;
    for(int i = 0; i < n; ++i){
        h += a[i];
        if(h <= x) ++ans;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string n;cin>>n;
  string t=n;
  reverse(t.begin(),t.end());
  if(t==n){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3560
"use strict";
// inputに入力データ全体が入る
const main = (input) => {
  const [a, b] = input.trim().split(" ").map(Number);
  return a + b < 10 ? `${a + b}` : "error";
};

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 29428
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int> ,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
long long MOD = 998244353;
pair<int,int> dx[4] = {{1,0},{-1,0},{0,1},{0,-1}};
long long fastpow(long long x,long long k)
{
    if(!k)
        return 1;
    if(k & 1)
        return ((x * fastpow(x,k-1) % MOD) % MOD) % MOD;
    long long ans = fastpow(x,k/2);
    ans %= MOD;
    ans *= ans;
    ans %= MOD;
    return ans;
}
long long sumF(long long x)
{
    int s = 0;
    while(x)
        s += x%10,x /= 10;
    return s;
}
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    int toEat = min(a,c);
    c -= toEat;
    int toEat2 = min(b,c);
    b -= toEat2;
    c -= toEat2;
    cout << toEat + toEat2*2 + (c > 0) + b;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays; 
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    sc.nextInt();
    int k = sc.nextInt();
    char[] letters = sc.next().toCharArray();
    letters[k-1] += 32;
    String output = String.valueOf(letters);
    System.out.println(output);
  }
}

Measured memory_bytes: 21844
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
  if i == 0:
    ans += b[i]
  elif a[i] - a[i-1] != 1:
    ans += b[i]
  else:
    ans += b[i] + c[a[i-1]-1]
print(ans)

Measured memory_bytes: 3064
#include<iostream>

int main()
{
	int b, r, g, c, s, t;
	while( std::cin >> b >> r >> g >> c >> s >> t, b | r | g | c | s | t )
	{
		int seven = -3 * b + 15 * b + 5 * b * 13;
		t -= b + 5 * b;
		int bar = -3 * r + 15 * r + 3 * r * 13;
		t -= r + 3 * r;
		int grape = -3 * g + 7 * g;
		t -= g;
		int cherry = -3 * c + 2 * c;
		t -= c;
		int star = -3 * s;
		t -= 2 * s;

		std::cout << 100 + seven + bar + grape + cherry + star + t * -3 << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 200005
int n, k;

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

    cin >> n >> k;
    ll mult = n/k;
    ll res = mult*mult*mult;
    if(k % 2 == 0){
        ll ot = (n+k/2)/k;
        res += ot*ot*ot;
    }
    cout << res << "\n";
    
    return 0;
}


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

int main() {
  int s;
  cin >> s;
  vector<bool> done(10000000, false);
  int cnt = 0;
  while (true) {
    cnt++;
    if (done.at(s)) {
      cout << cnt << endl;
      break;
    }
    else {
      done.at(s) = true;
      if (s % 2 == 0) {
        s /= 2;
      }
      else {
        s = 3 * s + 1;
      }
    }
  }
}


Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
string N;

int main() {
  INCANT;
  cin >> N;
  string ans = N[0]=='7' || N[1]=='7' || N[2]=='7'?"Yes":"No";
  cout << ans << "\n";
  return 0;
}

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

using namespace std;

int main(){
	int n;
	vector<int> v(n);
	cin >> n;
	int sum=1;
	int minus=1;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		//cout << a << endl;
		if(a%2==0){
			minus=minus*2;
		}
		sum=sum*3;
	}
	//cout << sum << endl;
	//cout << minus << endl;
	cout << sum - minus << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>

int main() {
	int n, m;
	std::cin >> n >> m;
	std::vector<std::vector<int>> lamps(m);
	for (auto& lamp : lamps) {
		int k; std::cin >> k;
		lamp = std::vector<int>(k);
		for (auto& s : lamp) {
			std::cin >> s;
			--s;
		}
	}
	std::vector<int> ps(m);
	for (auto& p : ps) std::cin >> p;
	auto count = 0;
	for (auto state = 0; state < (1 << n); ++state) {
		auto all_on = true;
		for (auto i = 0; i < m; ++i) {
			auto& lamp = lamps[i];
			int temp = 0;
			for (auto& s : lamp) {
				if ((state & (1 << s)) != 0) {
					++temp;
				}
			}
			if (ps[i] != temp % 2) {
				all_on = false;
				break;
			}
		}
		if (all_on) ++count;
	}
	std::cout << count << std::endl;
}



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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;
int A[100001];
int B[100001];
int C[100001];
int x,y,a,b,c;
int find(int idx)
{
    int temp=0;
    for(int j=0;j<=y;j++)
    {
        if((x-idx)+(y-j)<=c)
        {
            temp=max(temp,B[j]+C[(x-idx)+(y-j)]);
            // cout<<B[j]<<" "<<C[(x-idx)+(y-j)]<<endl;
        }
    }
    return temp+A[idx];
}
int32_t main() {
    nitin;
    cin>>x>>y>>a>>b>>c;
    for(int i=1;i<=a;i++)
        cin>>A[i];
    for(int i=1;i<=b;i++)
        cin>>B[i];
    for(int i=1;i<=c;i++)
        cin>>C[i];
    sort(A+1,A+a+1,greater<int>());
    sort(B+1,B+b+1,greater<int>());
    sort(C+1,C+c+1,greater<int>());
//    for(int i=0;i<=a;i++)
//        cout<<A[i]<<" ";
//    cout<<endl;
//    for(int i=0;i<=b;i++)
//        cout<<B[i]<<" ";
//    cout<<endl;
//    for(int i=0;i<=c;i++)
//        cout<<C[i]<<" ";
//    cout<<endl;
    for(int i=1;i<=a;i++)
        A[i]+=A[i-1];
    for(int i=1;i<=b;i++)
        B[i]+=B[i-1];
    for(int i=1;i<=c;i++)
        C[i]+=C[i-1];

    int start=0;
    int end=x;
    int ans=0;
    ans=max(find(0),find(end));
    for(int i=0;i<60;i++)
    {
        int mid=(start+end)/2;
        int val=find(mid);
        int val2=find(mid+1);
        ans=max(ans,val);
        if(mid+1<=x)
            ans=max(ans,val2);
        if(val>val2)
        {
            end=mid+1;
        }
        else{
            start=mid;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5960
#include <iostream>

using namespace std;

int main(){
   int a,b, ans =0 ;
   cin >> a >> b;

   if(a>b){
      ans += a;
      //ans = ans + a でもよい
      a -= 1;
   }
   
   else {
      ans += b;
      b -= 1;
   }

   // once more
    if(a>b){
      ans += a;
      //ans = ans + a
      a -= 1;
   }
   
   else {
      ans += b;
      b -= 1;
   }

   cout << ans << endl;
}

   

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()
# sys.setrecursionlimit(100000)


def main():
    x, a, b = [int(i) for i in input().strip().split()]
    res = a - b
    if res >= 0:
        print("delicious")
    elif abs(res) > x:
        print("dangerous")
    else:
        print("safe")

    return


if __name__ == "__main__":
    main()


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

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<ll>;
using vpii = vector<pii>;
using mpii = map<int, int>;
using mpci = map<char, int>;
using mpsi = map<string, int>;
using si = set<int>;
using sll = set<ll>;

#define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// a^n mod を計算する
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;
}

bool custom1 (pii a, pii b) {
  return (a.first < b.first);
}

bool custom2 (pii a, pii b) {
  return (a.second < b.second);
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  map<int, int> count;
  bool yes = true;
  for(int i=0;i<n;i++) {
    count[a[i]]++;
    if(count[a[i]] == 2) {
      yes = false;
      break;
    }
  }
  if(yes) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int n,m;cin >> n >> m;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  vector<int> a(m), b(m);
  rep(i,m) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }

  vector<bool> f(n, true);
  rep(i,m) {
    if(h[a[i]] < h[b[i]]) f[a[i]] = false;
    else if(h[a[i]] > h[b[i]]) f[b[i]] = false;
    else {
      f[a[i]] = false;
      f[b[i]] = false;
    }
  }

  int res = 0;
  rep(i,n) {
    if(f[i]) res++;
  }
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 4576
INF = 10 ** 10
n, ma, mb = gets.split.map(&:to_i)
chemicals = []
n.times { chemicals << gets.split.map(&:to_i) }

# dp[確認済の薬][タイプA量][タイプB量]の最安値
dp = (n + 1).times.map { 401.times.map { Array.new(401, INF) } }
# 初期化
# dp[0 個目の薬まで確認][タイプA量は 0][タイプB量は 0]の最安値は 0
dp[0][0][0] = 0

# n 個分ループする(i は遷移元の num)
n.times do |i|
  dp_current = dp[i]
  dp_next = dp[i + 1]
  391.times do |a|
    391.times do |b|
      current_cost = dp_current[a][b]
      dp_next[a][b] = current_cost if dp_next[a][b] > current_cost
      buying_a, buying_b, cost = chemicals[i]
      dp_next[a + buying_a][b + buying_b] = current_cost + cost if dp_next[a + buying_a][b + buying_b] > current_cost + cost
    end
  end
end

current_a = ma
current_b = mb

prices = []
until current_a > 400 || current_b > 400
  prices << dp[n][current_a][current_b]
  current_a += ma
  current_b += mb
end
puts prices.min == INF ? -1 : prices.min


Measured memory_bytes: 66496
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

typedef struct  {
	int w, h, size;
}graph;

vector<graph> g;
bool compare(graph a, graph b){
	if(a.size < b. size){
		return true;
	} else{
		if(a.size == b.size && a.h < b.h){
			return true;
		}
	}
	return false;
}

int main(int argc, char const* argv[])
{
	int h, w;
	
	for(int i = 1; i < 151; i++){
		for(int j = i+1; j < 151; j++){
			graph a;
			a.h = i;
			a.w = j;
			a.size = i * i + j * j;
			g.push_back(a);
		}
	}
	
	sort(g.begin(), g.end(), compare);
	
	
	while(true){
		cin >> h >> w;
		if(!(h&&w))break;
		
		rep(i, g.size()){
			if(g[i].h == h && g[i].w == w){
				cout << g[i+1].h << ' ' << g[i+1].w << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1348