akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define fr(i, n) for (i = 0; i < n; i++)
#define rep(i, n) for (i = 1; i <= n; i++)
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}; // trick to explore an implicit 2D grid
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; // S,SE,E,NE,N,NW,W,SW neighbors  //GO FOR EVEN FOR 4 moves

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
const int MAXN=500000;
int n, t[4*MAXN];
vector<int> cnt(MAXN,0);
void build(int v, int tl, int tr)
{
    if (tl == tr)
    {
        t[v] = cnt[tl];
    }
    else
    {
        int tm = (tl + tr) / 2;
        build(v * 2, tl, tm);
        build( v * 2 + 1, tm + 1, tr);
        t[v] = t[v * 2] + t[v * 2 + 1];
    }
}

int sum(int v, int tl, int tr, int l, int r)
{
    if (l > r)
        return 0;
    if (l == tl && r == tr)
    {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return sum(v * 2, tl, tm, l, min(r, tm)) + sum(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
}

void update(int v, int tl, int tr, int pos, int new_val)
{
    if (tl == tr)
    {
        t[v] = new_val;
    }
    else
    {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v * 2, tl, tm, pos, new_val);
        else
            update(v * 2 + 1, tm + 1, tr, pos, new_val);
        t[v] = t[v * 2] + t[v * 2 + 1];
    }
}

int main()
{
    fastinput;
    LL n, i, j, k, t, temp, tc;
    int q;
    cin>>n>>q;
    int tot=q;
    vector<LL> arr(n);
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        arr[i]--;
    }
    int pos_last[n],ans[q];
    for(i=0;i<n;i++)
    {
        pos_last[i]=-1;
        cnt[i]=0;
    }
    build(1,0,n-1);
    vector<pair<int,int>> queries[n];
    tc=-1;
    while(q--)
    {
        tc++;
        cin>>j>>k;
        j--;
        k--;
        queries[k].pb({j,tc});        
    }

    for(i=0;i<n;i++)
    {
        //debug(i);
        int breed=arr[i];
        int prev=pos_last[breed];
        if(prev!=-1)
        {
            cnt[prev]--;
            update(1,0,n-1,prev,cnt[prev]);
        }
        pos_last[breed]=i;
        cnt[i]++;
        update(1,0,n-1,i,cnt[i]);
        for(auto x:queries[i])
        {
            int id,lb;
            tie(lb,id)=x;
            int cal=sum(1,0,n-1,lb,i);
            //debug(lb);
            //debug(cal);
            ans[id]=cal;
        }
    }

    for(i=0;i<tot;i++)
    {
        cout<<ans[i]<<endl;
    }


    return 0;
}


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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    int n;
    cin>>n;
    vvi a(n, vi(3));
    for(int i=0; i<n; i++) {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    vvi dp(n+1, vi(3));
    for(int i=n-1; i>=0; i--) {
        for(int j=0; j<3; j++) {
            for(int jj=0; jj<3; jj++) {
                if(jj==j) continue;
                dp[i][j] = max(dp[i][j], dp[i+1][jj] + a[i][jj]);
            }
        }
    }
    cout << max(dp[0][0], max(dp[0][1], dp[0][2])) << "\n";
    return 0;
}



Measured memory_bytes: 11264
def myAnswer(N:int,A:list) -> None:
   MAX1 = max(A)
   tmp = A[:]
   tmp.remove(MAX1)
   MAX2 = max(tmp)
   for i in range(N):
      if(A[i] == MAX1):
         print(MAX2)
      else:
         print(MAX1)

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   A =[]
   for _ in range(N):
      A.append(int(input()))
   myAnswer(N,A)

if __name__ == '__main__':
   main()

Measured memory_bytes: 14068
n = int(input())
a = [float("inf")] * n
b = list(map(int, input().split()))


def solve():
    for i in range(n - 1):
        a[i] = min(a[i], b[i])
        a[i + 1] = min(a[i + 1], b[i])

    return sum(a)


print(solve())


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
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; }
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

Graph G;
vector<int> dp;

int dfs(int v){
    if(dp.at(v) != -1) return dp.at(v);

    int res = -1;

    for(auto nv : G.at(v)){
        chmax(res,dfs(nv));
    }

    return dp.at(v) = res+1;
}
int main(){

    int n,m; cin >> n >> m;
    G.resize(n);
    rep(i,m){
        int x,y; cin >> x >> y;
        --x;--y;
        G.at(x).push_back(y);
    }
    dp.assign(n,-1);

    int ans = -1;
    rep(i,n) chmax(ans,dfs(i));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;
ll lucas[87] = {2, 1};

ll calc(int n){
	if(lucas[n])
		return lucas[n];
	return lucas[n] = calc(n - 1) + calc(n - 2);
}

void solve(){
	cout << calc(N) << endl;
}

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


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

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = ReadInt();
            var div = X / 100;
            var rem = X % 100;
            if (rem >= 0 && rem <= div * 5)
            {
                Console.WriteLine(1);
                return;
            }

            Console.WriteLine(0);
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13140
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CStrangeDance {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      string t; cin >> t;

      // initialize vector size
      vector<vector<vector<int>>> v(3, vector<vector<int>>(n));
      int k = 1;
      rep(i, n) {
        rep(j, 3) {
          v[j][i].resize(k);
        }
        k *= 3;
      }
      int K = k;

      // initialize vector
      rep(i, n) {
        int idx = 0;
        rep(j, 3) {
          for(auto& e: v[j][i]) {
            e = idx;
            idx++;
          }
        }
      }

      for(auto c: t) {
        if (c=='S') {
          // swap vector
          swap(v[1], v[2]);
        } else {
          // swap by point
          int w = 0;
          rep(i, n) {
            auto v0 = v[0][i][w];
            auto v1 = v[1][i][w];
            auto v2 = v[2][i][w];
            v[1][i][w] = v0;
            v[2][i][w] = v1;
            v[0][i][w] = v2;
            w = v2;
          }
        }
      }

      // recover
      vector<int> ans(K);
      k = 1;
      rep(i, n) {
        for(int j=1; j<=2; j++) {
          for(auto e: v[j][i]) {
            for(int idx=e; idx<K; idx+=(k*3)) {
              ans[idx] += j*k;
            }
          }
        }
        k *= 3;
      }

      for(auto e: ans) {
        cout << e << ' ';
      }
    }
};

signed main() {
  CStrangeDance solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll 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(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    string s,t;
    cin >> s >> t;
    t.pop_back();

    if(s==t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632
N,M = map(int,input().split())
AB = []

for n in range(0,N):
  i = input().split(" ")
  AB.append([int(i[0]),int(i[1])])


AB.sort()

nowBuy = 0
allcost = 0

for a in AB:
  cost = a[0]
  canBuy = a[1]
  if nowBuy + canBuy > M:
    allcost += cost*(M - nowBuy)
    break
  else:
    nowBuy += canBuy
    allcost += canBuy*cost

print(allcost)



Measured memory_bytes: 20012
using System;

public class AtCoderA
{
    static void Main()
    {
        int a;
        int b;
        int c;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            a = int.Parse(words[0]);
            b = int.Parse(words[1]);
            c = int.Parse(words[2]);
        }

        string answer = (a + b + c) >= 22 ? "bust" : "win";

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
  rep(i,n) scanf("%d", &vec[i]);

  int current=0;
  long res=0;
  rep(i,n){
    // vec[i]について
    // current+1以上を配っていく
    if(vec[i] <= current) continue;
    if(vec[i] == current+1){current++; continue;}
    res += (long) (vec[i]-1) / (current+1);
    if(i==0) current=1;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using f32 = float;
using f64 = double;
using i8 = int_fast8_t;
using u8 = uint_fast8_t;
using i16 = int_fast16_t;
using u16 = uint_fast16_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
void resolver();
inline void fast_io()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}
template <class T>
inline std::vector<T> read_vector()
{
    size_t n;
    std::cin >> n;
    std::vector<T> ret(n);
    for (T& i : ret) {
        std::cin >> i;
    }
    return ret;
}
void t_case()
{
    i64 t;
    std::cin >> t;
    while (t--) {
        resolver();
    }
}
void single_case()
{
    resolver();
}

int main(int argc, char* argv[])
{
    fast_io();
    // t_case();
    single_case();
}

void resolver()
{
    using namespace std;

    i32 t;
    cin >> t;
    if (t % 10 == 7 || t / 100 == 7 || t / 10 % 10 == 7) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


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

int main (){
  int N,A,B;
  cin >> N >>A >> B;
  int num =0;
  for(int i =0;i<=N;i++){
    int a[5];
    a[0] = i/10000;
    a[1] = (i-a[0]*10000)/1000;
    a[2] = (i-a[0]*10000 - a[1]*1000)/100;
    a[3] = (i-a[0]*10000 - a[1]*1000 -a[2]*100)/10;
    a[4] = i-a[0]*10000 - a[1]*1000 -a[2]*100-a[3]*10;
    int sum =0;
    for(int j=0;j<5;j++){
      sum += a[j];
    }
    if(sum>=A &&sum<=B)
      num += i;
    
  }
  
  cout << num <<endl;
  
}



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

typedef long long ll;

void display(void* array, const size_t total_elems, const size_t size) {
    int i;
    switch (size) {
    case sizeof(char) :
	for(i=0; i<total_elems; i++) 
	    printf ("%d ",*(((char*)array)+i));
	printf ("\n");
	break;
    case sizeof(int) :
	for(i=0; i<total_elems; i++) 
	    printf ("%d ",*(((int*)array)+i));
	printf ("\n");
	break;
    case sizeof(long long) :
	for(i=0; i<total_elems; i++) 
	    printf ("%Ld ",*(((long long*)array)+i) );
	printf ("\n");
	break;
    }

}

static void _swap_char(char* a, char* b) {
    
    char  tmp = *a;
    *a = *b;
    *b = tmp;
}
void reverse(void *array, const size_t total_elems, const size_t size) {
    int i,j;
    for(i=0; i<total_elems/2; i++) {
	for(j=0; j<size; j++) {
	    _swap_char( ((char*)array)+size*i+j, ((char*)array)+size*(total_elems-i-1)+j );
	}
    }
}

int ll_comp(const void* a, const void* b) {
    ll A = *(ll*)a;
    ll B = *(ll*)b;
    int ans;
    if( A > B )  ans = 1; 
    if( A == B ) ans = 0;
    if( A < B )  ans = -1;
    return ans;
}
int comp(const void* a, const void* b) {
    int A = *(int*)a;
    int B = *(int*)b;
    int ans;
    if( A > B )  ans = 1; 
    if( A == B ) ans = 0;
    if( A < B )  ans = -1;
    return ans;
}
int main () {
    ll N;
    int a[110];
    int i;
    scanf("%Ld",&N);

    for(i=0; i<N; i++) {
	scanf("%d",&a[i]);
    }

    qsort(a,N,sizeof(int),comp);   
    reverse(a,N,sizeof(int));
    
    ll ans = 0;
    for(i=0; i<N; i++) {
	if(i%2 == 0)
	    ans += a[i];
	else
	    ans -= a[i];
    }
    printf("%Ld\n",ans);
    return 0;
}


Measured memory_bytes: 128
a = int(input())
arr = [int(i) for i in input().split()]
arr.sort() 
count = 0
for i in range(0,a-2): 
    k = i + 2
    for j in range(i+1,a):
        while (k < a and arr[i] + arr[j] > arr[k]): 
            k += 1
        if(k>j): 
            count += k - j - 1
  
print(count)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using ll=long long;
using ld=long double;

map<pair<int,int>, ll> memo;
ll combination(int n, int k){
  if(n-k<k) k=n-k;
  if(k==0) return 1;
  if(k==1) return n;
  ll& a=memo[make_pair(n-1,k)];
  if(a==0) a=combination(n-1,k);
  ll& b=memo[make_pair(n-1,k-1)];
  if(b==0) b=combination(n-1,k-1);
  //  cout<<n<<","<<k<<" "<<a+b<<endl;
  return a+b;
}

int n,a,b;
ll v[51];
int main(){ _;
  cin>>n>>a>>b;
  REP(i,n) cin>>v[i];
  sort(v,v+n,greater<ll>());
  ld avgMax=0;
  ll comb=0;
  for(int j=a;j<=b;j++){
    ll sm=0;
    REP(i,j) sm+=v[i];
    ld avg = static_cast<ld>(sm)/j;
    if(avg<avgMax) continue;
    if(avg>avgMax){
      avgMax=avg;
      comb=0;
    }
    int cnt=0,used=0;
    REP(i,n)
      if(v[i]==v[j-1]){
	cnt++;
	if(i<j)
	  used++;
      }
    comb+=combination(cnt,used);
  }
  cout<<fixed<<avgMax<<endl;
  cout<<comb<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N, M;
cin>>N;

int ans=0;
vector<string> blue(N);
for(int i=0;i<N;i++)
{
  cin>>blue.at(i);
}
cin>>M;
vector<string> red(M);
for(int i=0;i<M;i++)
{
  cin>>red.at(i);
}
for(int i=0;i<N;i++)
  {
    int b=0;
  string a=blue.at(i);
  for(int j=0;j<N;j++)
    {
      if(a==blue.at(j))
      b=b+1;
      else;
    }
    for(int k=0;k<M;k++)
    {
      if(a==red.at(k))
      b=b-1;
      else;
    }
    if(b>ans)ans=b;
    else;
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 3576
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();

    String[] s= br.readLine().split(" ");
    int n = Integer.parseInt(s[0]);
    int m = Integer.parseInt(s[1]);
    HashSet<Integer> oneAdj = new HashSet<>();
    HashSet<Integer> nAdj = new HashSet<>();
    for (int i=0; i<m; i++) {
      s = br.readLine().split(" ");
      int a = Integer.parseInt(s[0]);
      int b = Integer.parseInt(s[1]);
      if (a==1) {
        oneAdj.add(b);
      } else if (b==n) {
        nAdj.add(a);
      }
    }
    boolean possible = false;
    for (int i=2; i<n; i++) {
      if (oneAdj.contains(i) && nAdj.contains(i)) {
        possible = true;
        break;
      }
    }
    if (possible)
      System.out.println("POSSIBLE");
    else
      System.out.println("IMPOSSIBLE");
  }
}


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

int a[200][200],b[200][200];
int main(){
  int n;cin>>n;
  memset(b,0x3f,sizeof(b));
  for(int i=0;i<n;i++){
    int x,y,h;cin>>x>>y>>h;
    for(int cx=0;cx<=100;cx++){
      for(int cy=0;cy<=100;cy++){
        int ch=h+abs(cx-x)+abs(cy-y);
        if(h==0){
          b[cx][cy]=min(b[cx][cy],ch);
        }
        else{
          if(a[cx][cy]&&a[cx][cy]!=ch){
            a[cx][cy]=-1;
          }
          else{
            a[cx][cy]=ch;
          }
        }
      }
    }
  }
    for(int x=0;x<=100;x++){
      for(int y=0;y<=100;y++){
        if(a[x][y]>=0&&a[x][y]<=b[x][y]){
          cout<<x<<" "<<y<<" "<<a[x][y]<<endl;
        }
      }
    }
  }


Measured memory_bytes: 512
s=list(input())
n=len(s)
S=[]
t=0
while t<n-1:
    if s[t]=='B' and s[t+1]=='C':
        S.append('R')
        t+=1
    else:
        S.append(s[t])
    t+=1
if t==n-1:
    S.append(s[t])
m=len(S)
amount=0
bc=0
a=0
for i in range(m):
    if S[i]=='A':
        a += 1
    elif S[i]=='R':
        amount += a
        bc=1
    else:
        a=0
        bc=0
print(amount)

Measured memory_bytes: 12236
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
M = min(100, K + 1)

DP = [[0] * N for _ in range(M)]

for i in range(N):
  DP[0][i] = A[i]

for i in range(1, M):
  for j in range(N):
    DP[i][max(0, j - DP[i-1][j])] += 1
    t = j + DP[i-1][j] + 1
    if t < N:
      DP[i][t] -= 1
  for j in range(1, N):
    DP[i][j] += DP[i][j-1]

print(" ".join(map(str, DP[-1])))

Measured memory_bytes: 247204
function main(input){
    var alpha = [];
    for(var j=97;j<= 122;j++){
        alpha.push(String.fromCharCode(j));
    }
    var str = input.split("");
    var key;
    for(var i=0; i<str.length; i++){
        key = alpha.indexOf(str[i]);
        if(key>=0)
            alpha.splice(key,1);
    }

    if(alpha.length>0)
        console.log(alpha[0]);
    else
        console.log("None");
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 8476
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
int n,c,w[100009],v[100009],ans=0;
int A[100009],B[100009],C[100009],D[100009];
int W[1000009],w2[1000009];
main(){
  cin>>n>>c;
  r(i,n)cin>>w[i]>>v[i];

  r(p,2){
 
  r(i,n)W[i]=w[i];
 
  r(i,n)A[i]=v[i];
  r(i,n-1)A[i+1]+=A[i];
 
  r(i,n)B[i]=v[i];
  for(int i=n-1;i>0;i--)B[i-1]+=B[i];
  for(int i=n-1;i>=0;i--){
    if(i!=n-1)B[i]-=abs(c-w[i]);
    else B[i]-=abs(c-w[i]);
  }
  for(int i=n-1;i>0;i--){
    if(B[i-1]<=B[i]){
      B[i-1]=max(B[i-1],B[i]);
      W[i-1]=W[i];
    }
  }
  for(int i=0;i<n;i++){
    int sum=0;
    sum=A[i]-w[i];
    ans=max(ans,sum);
    if(i!=n-1)sum+=B[i+1];
    if(i!=n-1)sum-=min(abs(c-W[i+1]),w[i]);
    ans=max(ans,sum);
  }

  r(i,n/2)swap(w[i],w[n-i-1]);
  r(i,n/2)swap(v[i],v[n-i-1]);
  r(i,n)w[i]=abs(w[i]-c);

  }
 cout<<ans<<endl;
}

Measured memory_bytes: 8320
//AOJ GRL_2_A 無向辺

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long

typedef int Weight;
struct Edge {  //src:辺の始点,dst:辺の終点,weight:辺の重さ
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : //辺は重さが重いものを"小さい"と定義する
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

//引数 Graph:隣接リスト,r:最小全域木の始点
//戻値 total:最小全域木の重み,T:最小全域木の辺集合
pair<Weight, Edges> minimumSpanningTree(const Graph &g, int r = 0) {
  int n = g.size();
  Edges T;
  Weight total = 0;

  vector<bool> visited(n);
  priority_queue<Edge> Q;
  Q.push( Edge(-1, r, 0) );
  while (!Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (visited[e.dst]) continue;
    T.push_back(e);
    total += e.weight;
    visited[e.dst] = true;
    for(auto f=g[e.dst].begin();f!=g[e.dst].end();++f) if (!visited[f->dst]) Q.push(*f);
  }
  return pair<Weight, Edges>(total, T);
}
int main(){
  ll v,e;
  cin>>v>>e;
  Graph g(v);
  ll s,t,w;
  for(ll i=0;i<e;i++){
    cin>>s>>t>>w;
    g[s].push_back(Edge(s,t,w));
    g[t].push_back(Edge(t,s,w));
  }
  pair<Weight, Edges>x=minimumSpanningTree(g);
  ll ans=x.first;
  cout<<ans<<endl;
}



Measured memory_bytes: 8732
import collections
N,M = list(map(int,input().split()))
tree = [[] for _ in range(N)]
for _ in range(M):
    u, v = map(int, input().split())
    tree[u - 1].append(v - 1)  ##無効グラフであるので
    tree[v - 1].append(u - 1)




def dfs(now,prev,visited):
    
    if sum(visited) == 0:
        return 1
    
    ret = 0
    
    for nxt in tree[now]:
        if nxt != prev and visited[nxt] == 1:
            visited[nxt] = 0
            ret += dfs(nxt,now,visited)
            visited[nxt] = 1
    return ret
            
visited = [1 for _ in range(N)]
visited[0] = 0
print(dfs(0,-1,visited))


Measured memory_bytes: 3316
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

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

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

ll n, m;
vector<ll> G[half_inf + 10];
int c = 1;
int color[half_inf + 10];

bool dfs(ll v, int c) {
    color[v] = c;
    rep(i, G[v].size()) {
        if (color[G[v][i]] == 0) {
            if (!dfs(G[v][i], -c)) return false;
        } else if (color[G[v][i]] == c) return false;
    }
    return true;
}

void solve() {
    if (dfs(0, c)) {
        ll n_1 = 0, n_2 = 0;
        rep(i, n) {
            if (color[i] == c) n_1++;
            if (color[i] == -c) n_2++;
        }
        cout << n_1 * n_2 - m << endl;
    } else {
        cout << n * (n - 1) / 2 - m << endl;
    }
}

int main() {
    cin >> n >> m;
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    solve();
    return 0;
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    int h, w;
    cin >> h >> w;
    
    int a[h][w];
    rep(i, h) rep(j, w) cin >> a[i][j];
    
    vector<pair<pii, pii> > v;
    rep(i, h - 1) rep(j, w) {
        if (a[i][j] % 2 == 1) {
            a[i][j]--;
            a[i + 1][j]++;
            v.eb(make_pair(pii{i, j}, pii{i + 1, j}));
        }
    }
    
    rep(j, w - 1) {
        if (a[h - 1][j] % 2 == 1) {
            a[h - 1][j]--;
            a[h - 1][j + 1]++;
            v.eb(make_pair(pii{h - 1, j}, pii{h - 1, j + 1}));
        }
    }
    
    out(sz(v));
    rep(i, sz(v)) {
        out(v[i].F.F + 1 << " " << v[i].F.S + 1 << " " << v[i].S.F + 1 << " " << v[i].S.S + 1);
    }
}





Measured memory_bytes: 5232
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<bitset>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include <iomanip>
#include<map>


using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))

const ll MOD = 1e+9+7;
const double PI  = acos(-1.0);

int a[200010];
ll s[200010];

int get_mid_point(int l,int r,int c){
  ll diff_min=s[r]-s[l];
  FOR(i,c,r+1){
    ll sl=s[i]-s[l],sr=s[r]-s[i];
    ll diff=abs(sl-sr);
    if(diff>diff_min){
      return i-1;
    }else{
      diff_min=diff;
    }
  }
  return r;
}

int main(){
  int n;
  cin>>n;
  s[0]=0;
  REP(i,n){
    cin>>a[i];
    s[i+1]=a[i];
    s[i+1]+=s[i];
  }
  int pq=0,rs=3;
  ll ret=s[n];
  FOR(i,2,n){
    pq=get_mid_point(0,i,pq);
    rs=get_mid_point(i,n,rs);
    ll P=s[pq]-s[0],Q=s[i]-s[pq],R=s[rs]-s[i],S=s[n]-s[rs];
    ll diff = max(max(P,Q),max(R,S)) - min(min(P,Q),min(R,S));
    ret=min(ret,diff);
  }
  cout<<ret<<"\n";
}


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

void trace(int A[], int N) {
    int i;
    for ( i = 0; i < N; i++ ) {
        if ( i > 0 ) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

void insertionSort(int A[], int N) {
    int i, j, v;
    for ( i = 1; i < N; i++ ) {
        v = A[i];
        j = i - 1;
        while ( j >= 0 && A[j] > v ) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace(A, N);
    }
}

int main(int argc, char* argv[]) {
    int N, i;
    int A[100];

    cin >> N;
    for ( i = 0; i < N; i++ ) cin >> A[i];

    trace(A, N);
    insertionSort(A, N);

    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,k,c;cin>>n>>k>>c;
    string s;cin>>s;
    vin l(n),r(n);
    int res=0,cnt=1;
    while(res<n&&cnt<=k){
        if(s[res]=='o'){
            l[res]=cnt;
            cnt++;
            res+=c;
        }
        res++;
    }
    res=n-1;cnt=k;
    while(res>=0&&cnt>0){
        if(s[res]=='o'){
            r[res]=cnt;
            cnt--;
            res-=c;
        }
        res--;
    }
    rep(i,n)if(s[i]=='o'&&l[i]!=0&&r[i]!=0&&l[i]==r[i])cout<<i+1<<endl;
}

Measured memory_bytes: 5228
#include "bits/stdc++.h"

using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

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

    int N;
    cin >> N;

    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            if (i * j == N) {
                cout << "Yes" << "\n";
                return 0;
            }
        }
    }
    cout << "No" << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.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 (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, A, B;
        cin >> N >> A >> B;

        if ((N == 1 and (A != B)) or A > B) {
                cout << 0 << endl;
                return 0;
        } else if (N == 1) {
                cout << 1 << endl;
                return 0;
        }

        ll v1 = A * (N-2);
        ll v2 = B * (N-2);
        ll ans = v2 - v1 + 1;
        cout << ans << endl;
}

Measured memory_bytes: 3568
#include <stdio.h>
int main(void) {
   int i,n;
   int cha[100];

   scanf("%d", &n);
   for (i = 0; i < n; i++) {
       scanf("%d", &cha[i]); 
   }
   
   for (i = 0; i < n; i++) { 
       if (cha[i] % 2 == 0 && cha[i] % 3 != 0 && cha[i] % 5 != 0) { 
           puts("DENIED"); 
           return 0; 
       } 
   } 
   puts("APPROVED");

   return 0;
}

Measured memory_bytes: 128
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


n = int(input())
ans = 0
for i in range(11, n + 1, 2):
    res = make_divisors(i)
    if len(res) == 8:
        ans += 1
print(ans)


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

int main() {
  int H, W; // 1 ... 100
  cin >> H >> W;
  vector<string> a(H); // rows
  for(int i=0;i<H; i++){
    cin >> a.at(i);
  }
  // draw header
  for(int i=0;i<W+2;i++){
    cout << '#';
  }
  cout << endl;
  for(int i=0;i<H;i++){
    cout << '#' << a.at(i) << '#' << endl;
  }
  for(int i=0;i<W+2;i++){
    cout << '#';
  }
  cout << endl;
}


Measured memory_bytes: 256
function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const v = input[1].split(" ").map(n => Number(n));
  const c = input[2].split(" ").map(n => Number(n));
  let result = 0;
  for (let i = 0; i < n; i++) {
    const diff = v[i] - c[i];
    if (0 < diff) {
      result += diff;
    }
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<set>
#include<iostream>
#include<stdlib.h>
using namespace std;
typedef long long ll;

int main() {
	string s;
	cin >> s;
	int num = 0;
	for (int i = 0;i < 4;i++) {
		if (s[i] == '+')num++;
		if (s[i] == '-')num--;
	}
	cout << num << endl;
	return 0;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N, T;
	cin >> N >> T;
	int t[N];
	rep(i, N) cin >> t[i];
	ll ans = T;
	rep(i, N - 1) {
		ans += min(T, t[i + 1] - t[i]);
	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
 
int main() {
  vector<int> vec(3);
  cin >> vec[0] >> vec[1] >> vec[2];
  sort(vec.begin(), vec.end());
  cout << vec[2] * 10 + vec[1] + vec[0] << endl;
}

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

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

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

  sort(l.begin(), l.end());

  int ans = 0;
  for (int i = 0; i < n - 2; i++)
  {
    for (int j = i + 1; j < n - 1; j++)
    {
      for (int k = j + 1; k < n; k++)
      {
        if (l[k] > l[j] - l[i] && l[k] < l[i] + l[j]) {
          ans++;
        }
        if (l[k] >= l[i] + l[j]) {
          break;
        }
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int xmax = -1000;
        int ymin = 1000;
        int com;
        
        for(int i = 0; i < N; i++){
            com = sc.nextInt();
            if(xmax < com){
                xmax = com;
            }
        }
        for(int i = 0; i < M; i++){
            com = sc.nextInt();
            if(ymin > com){
                ymin = com;
            }
        }
        
       if (ymin <= xmax) {
			System.out.println("War");
			return;
		}
		if (ymin <= X) {
			System.out.println("War");
			return;
		}
		if (xmax >= Y) {
			System.out.println("War");
			return;
		}
		
			System.out.println("No War");
	}
}


Measured memory_bytes: 24916
#include<stdio.h>

int main(void)
{
   int n, d, x, i, j;
   int a[100];

   scanf("%d%d%d", &n, &d, &x);
   for(i=0;i<n;i++)
      scanf("%d",&a[i]);

   for(i=0;i<n;i++)
      for(j=1;j<=d;j++){
         if((j == 1)||((j-1) % a[i] == 0)){
            x = x + 1;}
}
   printf("%d\n", x);
   return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int l = in.nextInt();
		in.close();
		StringBuilder sb = new StringBuilder();
		String ls = System.lineSeparator();
		Stack<Integer> stack = new Stack<>();
		int node = 0;
		int edge = 0;
		while(l>0) {
			stack.add(l&1);
			l = l>>1;
		}
		node = stack.size();
		int num = node;
		int sum = 0;
		stack.pop();
		sum += pow2(num-1);
		while(!stack.isEmpty()) {
			num--;
			sb.append(num + " " + (num+1) + " " + 0 + ls);
			sb.append(num + " " + (num+1) + " " + pow2(num-1) + ls);
			edge += 2;
			if(stack.pop()==1) {
				sb.append(num + " " + node + " " + sum + ls);
				sum += pow2(num-1);
				edge += 1;
			}
		}
		System.out.println(node + " " + edge);
		System.out.println(sb.toString());
	}
	
	public static int pow2(int exp) {
		int ans = 1;
		for(int i=0;i<exp;i++) {
			ans *= 2;
		}
		return ans;
	}

}


Measured memory_bytes: 23124
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
        int i,j,t,k,minv,maxv;
        Scanner scan=new Scanner(System.in);
        t=scan.nextInt();
        int r[]=new int[t+1];
        for(i=0;i<t;i++)
        {
        	r[i]=scan.nextInt();
        }
        minv=r[0];
        maxv=r[1]-r[0];
        for(j=1;j<t;j++)
        {
        	maxv=Math.max(maxv,r[j]-minv);
        	minv=Math.min(minv,r[j]);
        }
        System.out.println(maxv);
	}

}

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

using namespace std;

string st;
string t;
vector<string> ss;

int main() {

	cin >> st >> t;
	
	string ans;
	ans.resize(st.length());
	bool flag;

	for (int i = 0; i < (st.length() - t.length())+1; i++) {
		for (int j = 0; j < t.length(); j++) {
			if (st[i + j] == t[j] || st[i + j] == '?') {
				ans[i + j] = t[j];
				flag = true;
			}
			else{
				for (int l = 0; l < ans.length(); l++) {
					ans[l] = 0;
				}
				flag = false;
				break;
			}
		}
		if (flag) {
			for (int k = 0; k < st.length(); k++) {
				if (st[k] == '?' && ans[k] == 0)
					ans[k] = 'a';
			}
			for (int k = 0; k < st.length(); k++) {
				if (ans[k] == 0)
					ans[k] = st[k];
			}
			ss.push_back(ans);
			for (int k = 0; k < ans.length(); k++)
				ans[k] = 0;
		}
	}

	sort(ss.begin(), ss.end());

	if (ss.size()==0)
		cout << "UNRESTORABLE" << endl;
	else
		cout << ss[0] << endl;


}

Measured memory_bytes: 3612
#include<cstdio>
#include<cstring>
#define max 100001
using namespace std;
int par[max],rank[max];
int vis[max];
void init(int N)
{
	for(int i=1;i<=N;i++)
	{
		par[i] = i;
		rank[i] = 0;
	}
}
int find(int x)
{
	if(par[x] == x)
	return x;
	else
	return par[x] = find(par[x]);
}

void unite(int x,int y)
{
	x = find(x);
	y = find(y);
	if(x == y)
	return ;
	
	if(rank[x] < rank[y])
	par[x] = y;
	else 
	{
		par[y] = x;
		if(rank[x] == rank[y])
		rank[x]++;
	}
	
}



int main()
{
	int N,M;
	while(~scanf("%d%d",&N,&M))
	{
		init(N);
		memset(vis,0,sizeof vis);
		int k,tmp;
		for(int i=1;i<=N;i++)
		{
			scanf("%d",&k);
			for(int j=1;j<=k;j++)
			{
				scanf("%d",&tmp);
				if(!vis[tmp])
				{
					vis[tmp] = i;
				}
				else if(vis[tmp] != i)
				{
					unite(vis[tmp],i);
				}
			}
		}
		int cnt = 0;
		for(int i=1;i<=N;i++)
		if(find(i) == i)
		cnt++;
		
		if(cnt == 1)
		printf("YES\n");
		else 
		printf("NO\n");
	}
	return 0;	
} 

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




int main(void){

	char str[1001];


	int q;

	char Q[101];


	int i;

	int a,b,m;


	scanf("%s",str);//??????????????£??\
	scanf("%d",&q);//?????°?????£??\

	for(i=0;i<q;i++){
	//	printf("??????????????\?????????????????????\n");
		scanf("%s",Q);

		if(strcmp(Q,"replace") == 0){

		//	printf("[replace]--a?????\?????????????????????\n");

			scanf(" %d",&a);

		//	printf("[replace]--b?????\?????????????????????\n");

			scanf(" %d",&b);
			m = (b-a)+1;
		//memcopy?????\??????

			
			char p[m];		
			
		

		//	printf("p?????\?????????????????????\n");

			scanf("%s",p);
			

			memcpy( a + str,p,m);

			

	//		printf("%s\n",str);

		}

		else if(strcmp(Q,"reverse") == 0){
			int s;
			int A=0;
			char re[1001];
			char tmp;
		
						
		
		//	printf("[reverse]--a?????\?????????????????????\n");

			scanf(" %d",&a);
			A = a;

		//	printf("[reverse]--b?????\?????????????????????\n");

			scanf(" %d",&b);

			strcpy(re,str);

		//	printf("str == [%s]\n",str);
		//	printf("re == [%s]\n",re);

			for(s = b;s > a;s--){
				
				tmp = re[A];
		//		printf("str[A] == [%c]?????????tmp \n",str[A]);



				str[A] = re[s];
		//		printf("str[s] == [%c] ???  str[A]  \n",str[s]);

				str[s] = tmp;
		//		printf("tmp == [%c] ???  str[s]  \n\n",tmp);
		//		printf("%s\n",str);

				A++;

			}
					
		//	printf("%s\n",str);

			
		/*	printf("str == [%s]\n",str);
			printf("re == [%s]\n",re);


			for(s = strlen(str) ;s >= 0; s--){
				
				str[] = re[s];

			}

		*/
		}

		else if(strcmp(Q,"print") == 0){
			int j;

		//	printf("[print]--a?????\?????????????????????\n");

			scanf(" %d",&a);

		//	printf("[print]--b?????\?????????????????????\n");

			scanf(" %d",&b);
			for(j=a;j <= b;j++){
			
				printf("%c",str[j]);

			}

			printf("\n");


//			printf("print ??????\n");


		}

	//	printf("i= %d  q = %d \n",i,q);

		//printf("for?????????\n");
	}

return 0;


}

Measured memory_bytes: 2776
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>

using namespace std;
#define SAY_YES cout<<"YES"<<endl;
#define SAY_Yes cout<<"Yes"<<endl;
#define SAY_NO cout<<"NO"<<endl;
#define SAY_No cout<<"No"<<endl;
#define IFYES(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} 
#define IFYes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} 
#define IFyes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"yes"<<endl;}else{cout<<"no"<<endl;} 
#define DEBUG_OUTPUT_ARRAY(XXX,ONE) for(int i=0;i<(ONE);i++){cout<<"DEBUG: i = "<<i<<" -> "<<XXX[i]<<endl;}
#define DEBUG_OUTPUT_ARRAY2(XXX,ONE,TWO) for(int i=0;i<(ONE);i++){cout<<"<<< i = "<<i<<" >>>"<<endl;for(int j=0;j<(TWO);j++){cout<<"DEBUG: j = "<<j<<" -> "<<XXX[i][j]<<endl; } }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX,ONE,TWO) for(int i=0;i<(ONE);i++){cout<<i<<"  ";for(int j=0;j<(TWO);j++){cout<<XXX[i][j]<<" "; } cout<<endl;}

typedef pair<long long int,long long int> pll;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int N,M,k[50],s[25][25],p[2200]={};
pair<long long int,long long int>star[205],allstar[1005];
map<pll,bool>mp;
int main() {
	cout << fixed << setprecision(18);
    cin>>N>>M;
    for(int i=0;i<M;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++){
            cin>>s[i][j];
            s[i][j]--;
        }
    }
    for(int i=0;i<M;i++){
        cin>>p[i];

    }
    long long int res=0;
    for(int i=0;i<(1<<N);i++){
        long long int tmp2=0;
        for(int j=0;j<M;j++){
            long long int tmp=0;
            for(int x=0;x<k[j];x++){
                if(((1<<s[j][x])&i)==0){
                    tmp++;
                }
            }
            if(tmp%2==p[j]){tmp2++;}
        }
        if(tmp2==M){
            res++;
        }
    }
    cout<<res;
} 


Measured memory_bytes: 384
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(gcd(a, b));

    }

    public static int gcd(int x, int y){
        int r;
        if (x < y) {
            swap(x, y);
        }
        while (y > 0) {
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    }
    public static void swap(int a,int b)

    {

        int temp=a;

        a=b;

        b=temp;

    }
}


Measured memory_bytes: 26168