akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5;
int n, h[maxN], memo[maxN];

int solve(int i)
{
  if (memo[i] != -1) return memo[i];
  if (i == n - 1) return memo[i] = 0;
  if (i == n - 2) return memo[i] = abs(h[i] - h[i + 1]);
  return memo[i] = min(solve(i + 1) + abs(h[i] - h[i + 1]), solve(i + 2) + abs(h[i] - h[i + 2]));
}
int main()
{
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &h[i]);
  memset(memo, -1, sizeof(memo));
  printf("%d\n", solve(0));
  return 0;
}

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

int main() {
  string N;
  cin >> N;
  int flag = 0;
  for (int i = 0; i < 3; i++) {
    if (N.at(i) == N.at(i + 1)) {
      cout << "Bad" << endl;
      flag = 1;
      break;
    }
    
    
  }
  if (flag == 0) {
    cout << "Good" << endl;
  }
  return 0;
}



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

int main() {
  int n;
  cin >> n;
  map<string,int>mp;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  int cnt = 0;
  for(auto p : mp){
    cnt = max(cnt, p.second);
  }
  for(auto p : mp){
    if(p.second==cnt) cout << p.first << endl;
  }
  return 0;
}


Measured memory_bytes: 25216
import sys

h, w = map(int, sys.stdin.readline().split())
grid = [sys.stdin.readline().rstrip() for _ in range(h)]

def main():
    res = [list(s) for s in grid if '#' in s]
    res2 = []
    for j in range(w):
        t = [s[j] for s in res]
        if '#' in t:
            res2.append(t)
    
    for j in range(len(res)):
        yield ''.join([s[j] for s in res2])

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
	int num, i = 0, sum = 0, buf, ma = 0;
	cin >> num;
	for (; i < num; i++) {
		scanf("%d", &buf);
		ma = max(ma, buf);
		sum += buf;
	}
	if (ma < sum - ma)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

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

print(*A)
for i in range(1, N):
  while A[i] < A[i-1] and i-1 >= 0:
    temp = A[i-1]
    A[i-1] = A[i] 
    A[i] = temp
    i -= 1
 
  print(*A)


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

int main() {
    string s;
    cin >> s;
    string ans;
    if (s == "AAA" || s ==  "BBB") {
        ans = "No";
    }
    else ans = "Yes";
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, k;
  cin >> n >> k;
  vector< ll > x(n);
  int idx = 0;
  while (idx < n) {
    ll xi;
    cin >> xi;
    if (xi == 0) {
      k--;
      n--;
      continue;
    }
    x[idx] = xi;
    idx++;
  }
  if (k <= 0) {
    cout << 0 << endl;
    return 0;
  }
  int tgt = -1;
  if (x[0] > 0) {
    tgt = 0;
  } else {
    for (int i=0; i<n; ++i) {
      if (x[i-1]<0 && x[i] > 0) {
        tgt = i;
        break;
      }
    }
  }
  if (tgt==-1) {
    cout << -x[n-k] << endl;
    return 0;
  } else if (tgt==0) {
    cout << x[k-1] << endl;
    return 0;
  } else {
    ll ans = abs(x[n-1])*2 + abs(x[0]);
    if (tgt+k-1<n) ans = min(ans, x[tgt+k-1]);
    if (tgt-k>=0) ans = min(ans, -x[tgt-k]);
    //cerr << ans << endl;
    for (int i=0; i<n; ++i) {
      if (i+k-1 < 0 || i+k-1 >= n) continue;
      if (x[i] > 0 || x[i+k-1] < 0) continue;
      ans = min(ans, -x[i]*2 + x[i+k-1]);
    }
    //cerr << ans << endl;
    for (int i=0; i<n; ++i) {
      if (i-k+1 < 0 || i-k+1 >= n) continue;
      if (x[i] < 0 || x[i-k+1] > 0) continue;
      ans = min(ans, x[i]*2 - x[i-k+1]);
    }
    cout << ans << endl;
  }
  return 0;
}


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

using namespace std;

int calc(int a, char op, int b)
{
    if (op == '+') {
        return a + b;
    } else if (op == '-') {
        return a - b;
    } else {
        return a * b;
    }
}

bool search(vector<int> &a)
{
    string op = "+-*";
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (calc(calc(a[0], op[i], calc(a[1], op[j], a[2])), op[k], a[3]) == 10) {
                    printf("((%d %c (%d %c %d)) %c %d)\n"
                           ,a[0], op[i], a[1], op[j], a[2], op[k], a[3]);
                    return 1;
                }
                if (calc(calc(a[0], op[i], calc(a[1], op[j], a[2])), op[k], a[3]) == 10) {
                    printf("(%d %c (%d %c %d) %c %d)\n"
                           ,a[0], op[i], a[1], op[j], a[2], op[k], a[3]);
                    return 1;
                } 
                if (calc(calc(a[0], op[i], a[1]), op[j], calc(a[2], op[k], a[3])) == 10) {
                    printf("((%d %c %d) %c (%d %c %d))\n"
                           ,a[0], op[i], a[1], op[j], a[2], op[k], a[3]);
                    return 1;
                }
            }
        }
    }
    return 0;
}

int main()
{
    vector<int> a(4);
    while (cin >> a[0] >> a[1] >> a[2] >> a[3], a[0]) {
        sort(a.begin(), a.end());
        
        bool found = 0;
        do {
            if (search(a)) {
                found = 1;
                break;
            }
        } while (next_permutation(a.begin(), a.end()));
        if (!found) {
            cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3172
function Main(input){

  input = input.split(' ');
  
  var a = Number(input[0]);
  var op = String(input[1]);
  var b = Number(input[2]);

  
var total = 0;
  if(op === '-') {
    total = a - b;
  } else {
      total = a + b;
  }
  console.log(total);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define ll long long

int main() {
	int n, k;
	cin >> n >> k;
	if (n % k == 0)cout << 0 << endl;
	else cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

bool ans[10][10];
bool ba[10][10];
int dx[] = {-1,0,0,0,1};
int dy[] = {0, -1,0, 1, 0};

bool judge(int x, int y) {
  int res = ba[x][y];
  REP(k,5) {
    int xx = x + dx[k];
    int yy = y + dy[k];
    if (xx < 0 || xx >= 10 || yy < 0 || yy >= 10) continue;
    if (ans[xx][yy]) res++;
  }
  return res % 2;
}

int main() {
  int n;
  cin >> n;
  while(n--) {
    REP(y,10)
      REP(x,10)
      cin >> ba[x][y];
    
    for (int i=0; i<(1<<10); ++i) {
      memset(ans, 0, sizeof(ans));
      REP(j,10)
        if ((i>>j)&1)
          ans[j][0] = 1;
      for(int y=1; y<10; ++y) {
        REP(x,10) {
          if (judge(x,y-1))
            ans[x][y] = 1;
        }
      }
      bool f = 1;
      REP(i,10)
        if (judge(i, 9)) f = 0;
      if (f) 
        break;
    }
    REP(y,10) {
      REP(x,10) {
        if (x) cout << " ";
        cout << ans[x][y];
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 0
n = gets.to_i
h = gets.split.map &:to_i

max = 0
count = 0

(0...h.size - 1).each{ |i|
	if h[i] >= h[i+1] then
		count += 1
	else
		if count > max then
			max = count
		end
		count = 0
	end
}

if count > max then
	max = count
end

puts max


Measured memory_bytes: 8580
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<vector>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC diagnostic error "-std=c++14"

#define isNum(a) (a>='0'&&a<='9')
#define SP putchar(' ')
#define EL putchar('\n')
#define ri register int

template<class T>
inline void in(T&);
template<class T>
inline void out(const T&);

typedef long long ll;
using std::min;
using std::max;
using std::abs;
using std::sort;
using namespace std;

int n,a[105],ans,sum;

int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    in(n);
    for (ri i=1;i<=n;++i) in(a[i]),sum+=a[i];
	for (ri i=1;i<=n;++i) ans+=(sum-a[i])*a[i];
	out(ans/2);EL; 
    return 0;
}

template<class T>
void in(T &Re)
{
    T k=0;
    char ch=getchar();
    int flag=1;
    while (!isNum(ch))
	{
        if (ch=='-')
		{
            flag=-1;
        }
        ch=getchar();
    }
    while (isNum(ch))
	{
        k=(k<<1)+(k<<3)+ch-'0';
        ch=getchar();
    }
    Re=flag*k;
}

template<class T>
void out(const T &Wr)
{
    if (Wr<0)
	{
        putchar('-');
        out(-Wr);
    }
	else
	{
        if (Wr<10)
		{
            putchar(Wr+'0');
        }
		else
		{
            out(Wr/10);
            putchar((Wr%10)+'0');
        }
    }
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

// a >= b
int gcd( int a, int b )
{
	// 引数に０がある場合は０を返す
	if ( ( a == 0 ) || ( b == 0 ) ) {
		return 0;
  }

  if (a < b) {
    swap(a, b);
  }

  // ユークリッドの互除法
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r =  a % b;
  }

  return b;
}

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

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

  int ans = gcd(hitpoint[0], hitpoint[1]);
  for (int i = 2; i < n; i++) {
    ans = gcd(ans, hitpoint[i]);
  }

  cout << ans << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int maxn = 400000 + 10;
 
template<typename T> T read() {
	T n(0), f(1);
	char ch = getchar();
	for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
	for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int n, m;
int a[maxn], b[maxn], Left[maxn];
int x[maxn], y[maxn], mark[maxn];

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif
    
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> a[i], ++ b[a[i]];

    for(int i = 1; i <= n; i++) 
        if(b[i]) {
            int j = i+n;
            for(int k = 1; k <= b[i]; ++k, --j) 
                ++ mark[j];

            Left[i] = j + 1;
        }else {
            Left[i] = i+n+1;
        }

    int ans = 0;
    for(int i = n+1; i <= 2*n; ++ i) if(mark[i]) ++ ans;

    for(int i = 1; i <= m; i++) {
        cin >> x[i] >> y[i];

        if(-- mark[Left[a[x[i]]]++] == 0)
            ans -= (Left[a[x[i]]] > n+1);

        a[x[i]] = y[i];

        if(++ mark[--Left[a[x[i]]]] == 1) 
            ans += (Left[a[x[i]]] > n);

        printf("%d\n", n - ans);
    }

    return 0;
}


Measured memory_bytes: 10112
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int pre[500005];
int pp[500005];
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   string s;
   cin>>s;
   int n=s.length();
   s="#"+s;
   int q;
   cin>>q;
   int x,z;
   char y;
   while (q--)
   {
      cin>>z;
      if(z==1)
      {
         pre[1]++;
         pre[n+1]--;
      }
      else
      {
         cin>>x>>y;
            s+=y;
            n++;
         if(x==1)
         {
            pp[n]=1;
         }
      }      
   }
   string ans1="",ans2="";
   for(int i=1;i<=n;i++)
   {
      pre[i]+=pre[i-1];
      if((pre[i]+pp[i])%2)
         ans2+=s[i];
      else
         ans1+=s[i];
   }
   reverse(ans2.begin(),ans2.end());
   ans2+=ans1;
   cout<<ans2;



// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }


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

using namespace std;

const int MAXN = 2e5 + 7;

int n;
int a[MAXN];

bool check(int c) {
    if (c == 1) {
        bool ans = 1;
        for (int i = 0; i < n - 1; ++i) {
            ans &= (a[i] < a[i + 1]);
        }   
        return ans;
    }
    
    map <int, int> d;
    for (int num = 1; num < n; ++num) {
        
        /*
        cout << num - 1 << " : ";
        for (int i = 0; i < a[num - 1]; ++i) {
            cout << (char)('a' + d[i]) << ' ';
        }   
        cout << '\n';
        */

        if (a[num - 1] < a[num]) {
            while (d.size()) {
                auto t = d.rbegin();
                if (t->first >= a[num - 1]) {
                    d.erase(t->first);
                }   
                else {
                    break;
                }   
            }
            continue;
        }   
        else {
            int p = a[num] - 1;
            bool ch = 0;
            for (int i = p; i >= 0; --i) {
                if (d[i] < c - 1) {
                    d[i]++;
                    ch = 1;
                    break;
                }   
                else {
                    d[i] = 0;
                }   
            }   
            if (!ch) {
                return 0;
            }   
        }   
    }   

    return 1;
}   

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

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

    int l = 0;
    int r = MAXN;
    while (l < r - 1) {
        int m = (l + r) >> 1;
        if (check(m)) {
            r = m;
        }   
        else {
            l = m;
        }   
    }   

    cout << r << '\n';
    return 0;
}   

Measured memory_bytes: 9856
#include <stdio.h>
#include <string.h>

int main(){
    char N[5];
    int i;

    scanf("%s", N);

    for (i = 0; i < 3; i++){
        if(N[i] == '7'){
            printf("Yes");
            return 0;
        }
    }

    printf("No");

    return 0;
}


Measured memory_bytes: 1732
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807

signed main()
{
int x=0,y=0,z=0,w=0,n=0;
string b;
stack<int> s;
while(std::cin >> x){
  if(x==0){
    std::cout << s.top() << '\n';
    s.pop();
  }else{
    s.push(x);
  }
}

}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define go(i, a, n) for (ll i = a; i < (ll)n; i++)
#define gor(i, a, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define gos(i, a, n, step) for (ll i = a; i < (ll)n; i += step)
#define show(a) cout << a << '\n'
#define show2(a, b) cout << a << " " << b << '\n'
#define show3(a, b, c) cout << a << " " << b << " " << c << '\n'
#define show4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << '\n'
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod 1000000007
#define mem(a, k) memset(a, k, sizeof(a))
#define answer(z, k) cout << "Case #" << z << ": " << k << endl;
auto t1 = chrono::high_resolution_clock::now();
ll numLen(ll K)
{

    // If K is a multiple of 2 or 5
    if (K % 2 == 0 || K % 5 == 0)
        return -1;

    ll number = 0;

    ll len = 1;

    for (len = 1; len <= K; len++)
    {

        // Instead of generating all possible numbers
        // 1, 11, 111, 111, ..., K 1's
        // Take remainder with K
        number = ((number * 10) + 7) % K;

        // If number is divisible by k
        // then remainder will be 0
        if (number == 0)
            return len;
    }

    return -1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    show(numLen(n));
    auto t2 = chrono::high_resolution_clock::now();
    auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
    clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
    return 0;
}

Measured memory_bytes: 3800
#include <stdio.h>

int main(){
    int r, c, i, j, v[101][101] = {};
    scanf("%d %d", &r, &c);
    for(i = 0; i < r; i++) for(j = 0; j < c; j++){
        scanf("%d", &v[i][j]);
        v[i][c] += v[i][j];
        v[r][j] += v[i][j];
        v[r][c] += v[i][j];
    }
    for(i = 0; i <= r; i++) for(j = 0; j <= c; j++) printf("%d%s", v[i][j], (j == c) ? "\n" : " ");
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

int min(vi x){
    sort(all(x));
    return x[0];
}

void Main(){
    int n, k; cin >> n >> k;
    vi a(n); 
    rep(i, n) cin >> a[i];
    
    rep(kk, k){
        vi b(n, 0);
        rep(i, n){
            int l = max(0, i-a[i]);
            int r = min(n-1, i+a[i]);
            b[l]++;
            if(r+1 < n) b[r+1]--;
        }
        rep3(i, 1, n-1){
            b[i] += b[i-1];
        }
        
        if(min(b) == n) {
            rep(i, n) cout << b[i] << " ";
            cout << endl;
            return;
        }
        a = b;
    }    

    rep(i, n) cout << a[i] << " ";
    cout << endl;
    
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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

int main() {
	int h, r;
	cin >> h >> r;
	if(h+r < 0) cout << -1 << endl;
	else if(h+r == 0) cout << 0 << endl;
	else cout << 1 << endl;
	return 0;
}


Measured memory_bytes: 3120
import java.io.*;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] nums = br.readLine().split(" ");
            int x = Integer.parseInt(nums[0]);
            int y = Integer.parseInt(nums[1]);

            while(y != 0) {
                int tmp = y;
                y = x % y;
                x =tmp;
            }
            System.out.println(x);
        } catch (IOException e) {
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 24416
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

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

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

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func modPow(a, n, mod int) int {
	ret := 1
	for n > 0 {
		if n&1 == 1 {
			ret = (ret * a) % mod
		}
		a = (a * a) % mod
		n >>= 1
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	const mod = 1000000007

	n := nextInt()
	a := nextInts(n)

	// ones[i]: i+1桁目が1である数の個数
	ones := make([]int, 60)
	for i := range a {
		for b, d := a[i], 0; b > 0; b, d = b>>1, d+1 {
			ones[d] += b & 1
		}
	}

	ans := 0
	for d := 0; d < 60; d++ {
		add := ones[d] * (n - ones[d])
		for e := 0; e < d; e++ {
			add = (add << 1) % mod
		}
		ans = (ans + add) % mod
	}

	puts(ans)
}


Measured memory_bytes: 6912
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long a = sc.nextInt();
		long b = sc.nextInt();
		long c = sc.nextInt();
		long d = sc.nextInt();
		// 出力
        System.out.println(Math.max(Math.max(a*c,a*d),Math.max(b*c,b*d)));
	}
}

Measured memory_bytes: 35772
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

def main():
    max_v, max_e = map(int, input().split())
    uf = WeightedUnionFind(max_v)
    k = []
    s = 0
    for i in range(max_e):
        a,b,w= map(int, input().split())
        a-=1
        b-=1
        if uf.same(a,b):
            if w != uf.diff(a,b):
                print("No")
                break
        else:
            uf.union(a,b,w)
    else:
        print("Yes")
if __name__ == '__main__':
    main()
 

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

int mod = 1e9+7;
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n,k,v;
    cin >> n;
    int res = 0;
    for(int i=1;i<=n;i++) {
        cin >> v;
        if(i%2 && v%2) res++;
    }
    cout << res;
}


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

int main() {
    int A,B,C,D;
    cin >>A>>B>>C>>D;
    int takahashi=(A-1)/D+1;
    int aoki = (C-1)/B+1;
    if(aoki<=takahashi){
        cout <<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)
#define MOD 1000000007

int n;
int w,h,x,y;

int main(){
  cin >> w >> h>>x>>y;
  cout<<(0.5*w*h)<<endl;
  if ((x*2==w)&(y*2==h)){
    cout<<(1)<<endl;
    return 0;
  }else{
    cout<<(0)<<endl;
    return 0;
  }

  return 0;
}

Measured memory_bytes: 256
n = int(input())
 
testimony = [[] for _ in range(n)]

for i in range(n):
    tmp = int(input())
    for j in range(tmp):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])
#print(testimony)

from itertools import product
s = [0,1]
ptns = sorted(list(product(s, repeat=n)), reverse=1)
#print(ptns)

for i in range(len(ptns)):
    #honest_or_not =[-1]*(n) # [-1, -1, -1]
    error = 0
    for j in range(n):
        if ptns[i][j] == 1: 
            for k in testimony[j]:
                if ptns[i][k[0]] != k[1]:
                    error = 1

    if error == 0:
        print(sum(ptns[i]))
        exit()



Measured memory_bytes: 9076
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(void) {

	int r, g, b;
	cin >> r >> g >> b;

	if ((100 * r + 10 * g + b) % 4 == 0)cout << "YES\n";
	else cout << "NO\n";

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define RANGEOF(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

template <class T> T read() { T t; cin >> t; return t; }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vector<vector<T>> read(int n, int m)
{
	vector<vector<T>> v;
	REP(i,n) { v.push_back(read<T>(m)); }
	return v;
}

template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }
template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__

void solve();
int main() { solve(); return 0; }

/// template end ///



void solve()
{
	vector<int> r;
	REP(i, 1000)
		r.push_back(i + 1);

	while (true)
	{
		READ(int, N,M,P);
		if (!(N|M|P)) { break; }
		
		auto v = read<int>(N);
		auto total = accumulate(ALLOF(v), 0);
		write(v[M-1] ? total * (100-P) / v[M-1] : 0);
	}
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int H1,M1,H2,M2,K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  
  int ans=(H2-H1)*60+M2-M1-K;
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <cctype>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long int64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e5+5, P = 1e9+7;
int n, a[N], d[N], rec[N], cir[N], size[N], c[N];
int64 ans = 1, f[N];
int main()
{
    n = read(); for(int i = 1; i <= n; ++i) a[i] = read(), ++d[a[i]];
    for(int i = 1, p; i <= n; ++i)
    {
        if(rec[i]) continue;
        p = i; while(!rec[p]) rec[p] = i, p = a[p];
        if(rec[p] == i) while(!cir[p]) cir[p] = 1, p = a[p];
    }
    for(int i = 1, k, p; i <= n; ++i) 
    {
        if((cir[i]&&d[i] > 2)||(!cir[i]&&d[i] > 1)) return puts("0"), 0;
        if(d[i]) continue; p = i, k = 0; 
        while(!cir[p]) ++k, p = a[p]; size[p] = k;
    }
    for(int i = 1, p, fir, j, k, firs; i <= n; ++i)
    {
        if(!cir[i]) continue;
        firs = fir = j = k = 0, p = i; 
        while(cir[p])
        {
            ++k, cir[p] = 0;
            if(size[p]&&!fir) j = fir = k, firs = size[p];
            else if(size[p]) ans = ans*((size[p] < k-j)+(size[p] <= k-j))%P, j = k;
            p = a[p];
        }
        if(!fir) ++c[k]; 
        else ans = ans*((firs < k-j+fir)+(firs <= k-j+fir))%P;
    }
    for(int i = 1; i <= n; ++i)
    {
        if(!c[i]) continue;
        f[0] = 1;
        for(int j = 1; j <= c[i]; ++j)
        {
            if(i > 1&&(i&1)) f[j] = (f[j-1]<<1)%P;
            else f[j] = f[j-1];
            if(j > 1) f[j] = (f[j]+f[j-2]*(j-1)%P*i%P)%P;
        }
        ans = ans*f[c[i]]%P;
    }
    printf("%lld\n", ans);
    return 0;
}
/* 
1
1 1
2
1 2 2
3
1 2 3 4
4
1 2 3 4 10
5
1 2 3 4 5 26
6
1 2 3 4 5 6 76
7
1 2 3 4 5 6 7 232
9
2 1 4 5 6 3 8 7 9
*/

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  double ave = 0;
  rep(i, n) {
    cin >> a[i];
    ave += a[i];
  }
  ave /= n;
  int ans = 0;
  double minv = INF;
  rep(i, n) {
    double diff = abs(ave - a[i]);
    if(minv > diff) {
      minv = diff;
      ans = i;
    }
  }
  cout << ans << endl;
  
}

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

int main()
{
    char a;
    cin>>a;
    int c=a;
    if(c>=65 && c<=91)
    {
        cout<<"A"<<endl;
    }
    else
    {
        cout<<"a"<<endl;
    }
    return 0;

}


Measured memory_bytes: 3632
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;cin>>n;
    ll a=2,b=1;
    vector<ll>c;
    c.pb(a);c.pb(b);
    for(int i=0;i<n-1;i++){
        ll t=a+b;
        c.pb(t);
        a=b;b=t;
    }
    cout<<c[n]<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#import<bits/stdc++.h>
long long i,m,n,s,w[100000];
main()
  {
  for(scanf("%lld",&n);i<n;w[i]<0?m++,w[i]*=-1:0,s+=w[i++])scanf("%lld",w+i);
  std::sort(w,w+n);
  printf("%lld",s-(m%2?2*w[0]:0));
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	vector<int> is(5);
	rep(i, 5) {
		cin >> is[i];
	}
	int ans = 0;
	rep(i, 5) {
		if (is[i] == 0) {
			ans += i + 1;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3584
import heapq
from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))
l = Counter(A)
#print(l)
dif = len(l) - K
if dif <= 0:
    print(0)
    exit()
l = list(l.values())
heapq.heapify(l)
#print(l)
ans = 0
for i in range(dif):
    ans += heapq.heappop(l)
print(ans)

Measured memory_bytes: 122228
#include <algorithm> // std::sort(begin,end), std::min, std::max
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <utility> // std::swap
#include <vector>

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

template <typename T> // 0<1<2<3<4
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
template <typename T> // 0>1>2>3>4
using pq_dsc = priority_queue<T>;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  int cnt = 0;
  for (int i = 1; i < n - 1; i++) {
    if ((v[i - 1] < v[i] && v[i] < v[i + 1]) ||
        (v[i - 1] > v[i] && v[i] > v[i + 1])) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int n, w;
int a[100][2], dp[101][11001];

int compare_int(const void* a, const void* b) { return ((int*) a)[0] - ((int*) b)[0]; }

int func(int x, int wsum) {
	if (wsum > w) {
		return 0;
	}
	int max = 0;
	for (int i = x + 1; n > i; i++) {
		if (!dp[i][wsum + a[i][0]]) 
			dp[i][wsum + a[i][0]] = func(i, wsum + a[i][0]);
		if (max < dp[i][wsum + a[i][0]]) max = dp[i][wsum + a[i][0]];
	}
	if(x != -1)	
		return max + a[x][1];
	else return max;
}

int main() {
	scanf("%d %d", &n, &w);
	for (int i = 0; n > i; i++) {
		scanf("%d %d", &a[i][1], &a[i][0]);
	}
	//qsort(a, n, sizeof(int), compare_int);
	printf("%d\n", func(-1, 0));
}

Measured memory_bytes: 5112
N,M,K = map(int,input().split())
fr = [[] for i in range(N+1)]
bl = [[] for i in range(N+1)]
for _ in range(M):
    A,B = map(int, input().split())
    fr[A].append(B)
    fr[B].append(A)
for _ in range(K):
    C,D = map(int, input().split())
    bl[C].append(D)
    bl[D].append(C)

leader = [0]*(N+1)
d = {}
for root in range(1,N+1):
    if leader[root]!=0:
        continue
    d[root] = set([root])
    stack = [root]
    while stack:
        start = stack.pop()
        leader[start] = root
        for v in fr[start]:
            if leader[v]!=0:
                continue
            d[root].add(v)
            stack.append(v)

ans = [0]*(N+1)
for i in range(1,N+1):
    cluster = d[leader[i]]
    ans[i] = len(cluster) - len(fr[i]) - 1
    for b in bl[i]:
        if b in cluster:
            ans[i] -= 1
print(*ans[1:])

Measured memory_bytes: 125052
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    int i,flag;
    scanf("%d",&N);
    
    flag=0;
    for(i=1;10>i;i++){
        if(N%i==0&&N/i<10){
            flag = 1;
            break;
        }
    }
    if(flag) printf("Yes\n");
    else     printf("No\n");
    
    return 0;
}


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

int s[101] = {0};

int main(){
    int n;
    scanf("%d",&n);
    int sum=0;
    for(int i=0;i<n;++i){
        scanf("%d",&s[i]);
        sum += s[i];
    }
    if(sum % 10 != 0)printf("%d\n",sum);
    else{
        sort(s, s+n);
        bool flag=false;
        for(int i=0;i<n;++i){
            if(s[i] % 10 != 0){
                printf("%d\n",sum-s[i]);
                flag = true;
                break;
            }
        }
        if(!flag)printf("0\n");
    }

    return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep (i, n) {
    cin >> a[i];
  }
  ll mi = 2, ma = 2;
  rrep (i, n) {
    ll mi2, ma2;
    if (mi % a[i] == 0) {
      mi2 = mi;
    }
    else {
      mi2 = mi / a[i] * a[i] + a[i];
    }
    if (mi2 > ma) {
      cout << -1 << endl;
      return 0;
    }
    ma2 = (ma / a[i] + 1) * a[i] - 1;
    mi = mi2;
    ma = ma2;
  }
  cout << mi << " " << ma << endl;
}
     


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n,k;
  cin >> n >>k;
  int ans = 0;
  ans += (n/k)*(n/k)*(n/k);
  if(k%2==0) {
    n += k/2;
    ans += (n/k)*(n/k)*(n/k);
  }
  cout << ans << endl;
}


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

int main()
{
    int N, i, left = 0, right = 0, mnm = 0;
    cin >> N;
    int W[N]; // 1 3 1 1

    for(i = 0; i < N; i++)
    {
        cin >> W[i];
        mnm += W[i];
        left += !i ? W[i] : 0;
        right += i ? W[i] : 0;
    }

    for(int i = 1; i < N; i++)
    {
        if(abs(right - left) < mnm)
        {
            mnm = abs(right - left);
            left += W[i];
            right -= W[i];
        }
    }

    cout << mnm << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i< (n); i++)
int main(){
vector<int> vec={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int K;
cin >> K;
cout << vec.at(K-1) << endl;  



}

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

int main()
{
	int n, k;
	cin >> n >> k;
	int a[n];
	int dp[k+1];
	memset(dp, 0, sizeof(dp));

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

	for(int i = a[0]; i <= k; i++)
	{
		for(int j = 0; j < n and !(dp[i]); j++)
		{
			if(i >= a[j] and !dp[i - a[j]])
			{
				dp[i] = 1;
				break;
			}
		}
	}

	if(dp[k])
		cout << "First";
	else
		cout << "Second";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll X;
    cin >> X;
    ll c = 0;
    ll d = 100;
    while (d < X) {
        d += d*0.01;
        c++;
    }
    cout << c << "\n";
}


Measured memory_bytes: 3652
#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)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;


#define MAX_N 10000
struct UnionFind{
    int par[MAX_N]; 
    void init(int n){
        for (int i=0;i<n;i++) par[i] = i;
    } 
    int find(int x){
        if (x==par[x]) return (x);
        return (par[x]=find(par[x]));
    }
    void unite(int x, int y){
        x=find(x);y=find(y);       
        if(x==y) return;
        par[x] = y;
    } 
    bool same(int x, int y){
        return (find(x) == find(y));
    } 
};

int main(){
    int n,q,c,x,y;
    UnionFind uf;
    cin>>n>>q;
    uf.init(n);
    rep(i,q){
        cin>>c>>x>>y;
        if(c==0) uf.unite(x,y);
        else{
            if(uf.same(x,y)) cout<<1<<endl;
            else cout<<0<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3116
s =input()
t =input()

S = len(s)
T = len(t)

cnt=0
max=0

for i in range(S-T+1):
    for j in range(T):
        if s[i+j] == t[j]:
            cnt += 1
    else:
        if max<cnt:
            max=cnt
            cnt=0
        else:
            cnt=0

print(T-max)


Measured memory_bytes: 8936
### classes

class SegTree
  def initialize(q, lim)
    @q = 1
    while @q < q
      @q <<= 1
    end
    @lim = lim
    @data = (@q * 2 - 1).times.map{0}
    @head = @tail = 0
  end

  def add
    s = @tail + @q - 1
    while s > 0
      @data[s] += 1
      s = (s - 1) / 2
    end
    @data[0] += 1
    @lim -= 1
    ret = @tail
    @tail += 1
    del_pos(@head) if @lim < 0
    ret
  end

  def find(x)
    s = 0
    while s < @q - 1
      s0 = s * 2 + 1
      k = @data[s0]
      if x <= k
        s = s0
      else
        x -= k
        s = s0 + 1
      end
    end
    s - (@q - 1)
  end

  def del_pos(x)
    s = x + @q - 1
    while s > 0
      @data[s] -= 1
      s = (s - 1) / 2
    end
    @data[0] -= 1
    @lim += 1

    while @head < @tail && @data[@head + @q - 1] == 0
      @head += 1
    end
  end

  def del(x)
    s = 0
    while s < @q - 1
      @data[s] -= 1
      s0 = s * 2 + 1
      k = @data[s0]
      if x <= k
        s = s0
      else
        x -= k
        s = s0 + 1
      end
    end
    @data[s] -= 1
    @lim += 1

    while @head < @tail && @data[@head + @q - 1] == 0
      @head += 1
    end
  end

  def print
    p ['@head', @head, '@tail', @tail]
    l = 1
    s = 0
    while l <= @q
      p @data[s, l]
      s += l
      l *= 2
    end
  end
end

### main

loop do
  q, lim = gets.split.map(&:to_i)
  break if (q | lim) == 0

  st = SegTree.new(q, lim)
  id2seq = {}
  seq2id = []
  #p st

  q.times do
    qi, xi = gets.split.map(&:to_i)
    #p ['query', qi, xi]

    case qi
    when 0
      seq = st.add
      seq2id[seq] = xi
      id2seq[xi] = seq
    when 1
      st.del(xi)
    when 2
      seq = st.find(xi)
      puts seq2id[seq]
      #p ['q2', seq, seq2id[seq]]
    when 3
      seq = id2seq[xi]
      st.del_pos(seq)
    end

    #st.print
    #p seq2id
    #p id2seq
  end

  puts 'end'
end

Measured memory_bytes: 43116
#include <cstdio>

int c(char a, char b, char c) {
    return (a - '0') * 100
        + (b - '0') * 10
        + (c - '0');
}

int main() {
    char c1, c2, c3;
    unsigned long long int a;
    int d;
    scanf("%lld %c.%c%c", &a, &c1, &c2, &c3);
    d = c(c1, c2, c3);
    printf("%lld\n", a * d / 100);
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl


int main() {
    int X, A;  cin >> X >> A;

    if (X< A) print(0);
    else print(10);
}


Measured memory_bytes: 764
/*  -*- coding: utf-8 -*-
 *
 * 2832.cc: All Japan Association of Return home
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

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

  int ct = 0, cf = 0, cd = 0;
  ll sum = 0;

  for (int i = 0; i < n; i++) {
    int ti, fi;
    scanf("%d%d", &ti, &fi);
    fi--;
    
    if (cf + fi <= ti - ct)
      sum += (ll)cd * cf, cd = 0;
    else if (abs(fi - cf) <= ti - ct && cd < d)
      sum += (ll)cd * (ti - ct);
    else {
      puts("-1");
      return 0;
    }

    ct = ti, cf = fi;
    cd++;
  }
  sum += (ll)cd * cf;
  
  printf("%lld\n", sum);
  return 0;
}



Measured memory_bytes: 3232
#include <iostream>
#include <cmath>

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

using namespace std;

int main()
{
	int count = 0;
	char c;
	double x[25],y[25];
	double ans = 0;
	while(cin >> x[count] >> c >> y[count])
	{
		count++;
	}

	x[count] = x[0];
	y[count] = y[0];

	rep(i,count)
	{
		ans += x[i]*y[i+1] - x[i+1]*y[i];
	}

	cout << abs(ans)/2.0 << endl;
	return 0;
}

Measured memory_bytes: 1284