akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define N 200001
#define Max 10000
#define NTL -1
struct Node{
    int p,l,r;
};
struct Node T[N];
int getDepth(int p){
    if(T[p].p == NTL) return 0;
    return getDepth(T[p].p)+1;
}
int main()
{
    int n,i,k,j,c;
    int id,tmp;
    int depth[N];
    scanf("%d",&n);
    for( i=0;i<n;i++){
        T[i].p=T[i].l=T[i].r=NTL;
    }
    for(i=0;i<n;i++){
        scanf("%d%d",&id,&k);
        for(j=0;j<k;j++){
            scanf("%d",&c);
            if(j==0){
                T[id].l=c;
                T[c].p=id;
                tmp=c;
            }
            else{
                T[tmp].r=c;
                T[c].p=id;
                tmp=c;
            }
        }
    }
    for(i=0;i<n;i++)
        depth[i]=getDepth(i);
    for(i=0;i<n;i++){
        printf("node %d: parent = %d, depth = %d, ",i,T[i].p,depth[i]);
        if(T[i].p==NTL)
            printf("root, [");
        else if(T[i].l==NTL)
            printf("leaf, [");
        else
            printf("internal node, [");
            if(T[i].l != NTL){
                printf("%d",T[i].l);
                tmp = T[i].l;
                while(1){
                    if(T[tmp].r==NTL) break;
                    printf(", %d",T[tmp].r);
                    tmp = T[tmp].r;
                }
            }
            printf("]\n");
        }
  return 0;
}


Measured memory_bytes: 3332
#include <iostream>
using namespace std;
int main(){
	string s;
  	cin >> s;
  	
  	int ans;
  	if(s == "SUN") ans =7;
  else if(s == "MON") ans =6;
  else if(s == "TUE") ans =5;
  else if(s == "WED") ans =4;
  else if(s == "THU") ans =3;
  else if(s == "FRI") ans =2;
  else if(s == "SAT") ans =1;
  
  cout<< ans << endl;
}


Measured memory_bytes: 3588
import java.io.*;
import java.util.*;

 
public class Main{
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      int N=sc.nextInt();
      int K=sc.nextInt();
      int p[]=new int[N];

      for(int i=0;i<N;i++){
          p[i]=sc.nextInt();
      }
      int csum=0;
      for(int i=0;i<K;i++){
          csum+=p[i];
      }
      int maxsum=csum;
      for(int i=1;i+K<=N;i++){
          csum-=p[i-1];
          csum+=p[i+K-1];
          maxsum=Math.max(maxsum, csum);
      }
      out.println(String.format("%.10f", (maxsum+K)/2.0));
      out.close();
   }

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;
      
   //-----------MyScanner class for faster input----------
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
 
      long nextLong() {
          return Long.parseLong(next());
      }
 
      double nextDouble() {
          return Double.parseDouble(next());
      }
 
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }
   }
}

Measured memory_bytes: 44316
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;
const int MOD = 1000000007;

int main(){
  string sf;
  cin >> sf;
  ll q;
  cin >> q;
  vector<ll> t(q+1);
  vector<ll> f(q+1);
  vector<char> c(q+1);
  for(int i=1; i<=q;i++){
    cin >> t.at(i);
    if(t.at(i) == 2){
      cin >> f.at(i) >> c.at(i);
    }
  }

  vector<string> s(2);
  ll con = 0;
  for(int i=1; i<=q;i++){
    if(t.at(i) == 1){
      if(con == 0){
        con = 1;
      }else{
        con = 0;
      }
    }else{
      if(f.at(i) == 1){
        if(con == 0){
          s.at(0) = s.at(0) + c.at(i);
        }else{
          s.at(1) = s.at(1) + c.at(i);
        }
      }else{
        if(con == 0){
          s.at(1) = s.at(1) + c.at(i);
        }else{
          s.at(0) = s.at(0) + c.at(i);
        }
      }
    }
  }
  if(con == 0){
    reverse(s.at(0).begin(),s.at(0).end());
    cout << s.at(0) + sf + s.at(1) << endl;
  }else{
    reverse(s.at(1).begin(),s.at(1).end());
    reverse(sf.begin(),sf.end());
    cout << s.at(1) + sf + s.at(0) << endl;

  }

}


Measured memory_bytes: 4912
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let v = read_vec::<u32>();
    //let s = read::<String>();
    let a = v[0];
    let p = v[1];

    let pies = (a * 3 + p) / 2;

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
 
int main(){
    int n;cin>>n;
    vector<int> a(n+1),b(n);
    rep(i,n+1)cin>>a[i];
    rep(i,n)cin>>b[i];
    ll ans=0;
    rep(i,n){
        if(a[i]<b[i]){
            if(a[i+1]<b[i]-a[i]){
                ans+=a[i]+a[i+1];
                a[i+1]=0;
            }
            else{
                ans+=b[i];
                a[i+1]-=b[i]-a[i];
            }
        }
        else{
            ans+=b[i];
            a[i]-=b[i];
        }
    }
    cout<<ans<<endl;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const intll INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  intll n , a , b ; 
  cin >> n >> a >> b ;
  
  intll ans= 0 ;
  if(b-a >= 0 ){
    ans = (n-2) * (b-a) + 1   ;
    if (n==1 && a!=b) ans = 0 ; 
    if (n==1 && a==b) ans = 1 ;
  }
  
  cout << ans  ;
  
}


Measured memory_bytes: 3600
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    bool pink, white, green, yellow;
    pink = white = green = yellow = 0;
    for (int i=0; i<N; i++){
        char si;
        cin >> si;
        if (si == 'P')pink = true;
        else if (si == 'W')white = true;
        else if (si == 'G')green = true;
        else if (si == 'Y')yellow = true;
    }
    if (pink+white+green+yellow == 4)cout << "Four" << endl;
    else cout << "Three" << endl;

}

Measured memory_bytes: 256
/*
    ALWAYS REMMEMBER:
        NEVER GIVE UP !
        DON'T MESS WITH ME !!!
        "" THE EXPERT IN ANYTHING WAS ONCE A BEGINNER ""
*/

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;

void solve()
{
    ll n,m;
    cin >> n >> m;

    cout << n*(n-1)/2 + m*(m-1)/2;
    
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 256
# AGC033A - Darker and Darker
# https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.distance_transform_cdt.html
from scipy.ndimage import distance_transform_cdt as dist


def main():
    """
    distance_transform_cdt:
        orig     taxicab / chessboard
        1 1 1     2 1 2      1 1 1
        1 0 1 ->  1 0 1      1 0 1
        1 1 1     2 1 2      1 1 1
    """
    H, W, *A = open(0).read().split()
    B = [[1 if i == "." else 0 for i in a] for a in A]
    D = dist(B, metric="taxicab")
    ans = D.max()
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 47744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int tary[n];
    rep(i,n) cin >> tary[i];
    int tsum = 0;
    rep(i,n) tsum+=tary[i];
    int m;
    cin >> m;

    rep(i,m) {
        int p,x;
        cin >> p >> x;
        --p;
        cout << tsum - tary[p] + x << endl;
    }

}


Measured memory_bytes: 256
#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>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int N, C;
int D[31][31];
int c[501][501];
int Z[31], O[31], T[31];

int draw(int zer, int one, int two){
    int ret = 0;
    rep(i,C){
        ret += D[i][zer]*Z[i] + D[i][one]*O[i] + D[i][two]*T[i];
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> C;
    rep(i,C)rep(j,C) cin >> D[i][j];
    rep(i,C){
        Z[i] = 0;
        O[i] = 0;
        T[i] = 0;
    }
    rep(i,N)rep(j,N){
        cin >> c[i][j];
        c[i][j]--;
        if((i+j)%3 == 0) Z[c[i][j]]++;
        else if((i+j)%3 == 1) O[c[i][j]]++;
        else T[c[i][j]]++;
    }
    int ans = 1e9;
    rep(i,C){
        rep(j,C){
            if(i == j) continue;
            rep(k,C){
                if(i == k || j == k) continue;
                chmin(ans, draw(i,j,k));
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main(){
  int i,j,cnt;
  int n;
  cin>>n;
  int b[n-1];
  for(i=0;i<n-1;i++)cin>>b[i];
  int sum=b[0]+b[n-2];
  for(i=0;i<n-2;i++){
    sum+=min(b[i+1],b[i]);
  }
  cout<<sum;
}

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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c)

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

int size(int n, int k)
{
  int cnt = 0;
  while(n)
  {
    cnt++;
    n /= k;
  }
  return cnt;
}

int main()
{
  ios::sync_with_stdio(0);
  int n,k;
  cin >> n >> k;
  cout << size(n,k) << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        if ((a + b) % 2 == 1) {
            System.out.println("IMPOSSIBLE");
        } else {
            System.out.println((a + b) / 2);
        }

    }
}


Measured memory_bytes: 20820
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------

int n ;
int s[1000];
int mx;

int mn=1000;
int sm;

int main(){
    cin>>n;
    REP(i,n){
        cin>>s[i];
        sm+=s[i];
        if(s[i]%10)mn=min(mn,s[i]);
    }
    if(sm%10){
        cout<<sm;
    }else{
        if(mn==1000)mn=0;
        if((sm-mn)%10)cout<<sm-mn;
        else cout<<0;
    }



    /*うーん　なんでビット全探索でとけないんだああああああああああああああああああ
       for(int i=0;i<(1<<n);i++){
        int sum=0;
        REP(j,n){
            sum+=s[j]*((i>>j)&1);
        }
        //cout<<sum<<endl;
        if((sum%10)==0)sum=0;
        mx=max(sum,mx);

    }
    cout<<mx;*/


    return 0;
}

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

using namespace std;

const int N = 1e4 + 10;
int f[N],dp[N],x[N];
vector<int>edge[N];
void dfs(int u)
{
    for(int i = 0;i < edge[u].size();i++)
        dfs(edge[u][i]);
    memset(dp,0x3f,sizeof(dp));
    dp[0] = 0;
    for(int i = 0;i < edge[u].size();i++)
    {
        int v = edge[u][i];
        for(int j = x[u];j >= 0;j--)
        {
            int inf = 0x3f3f3f3f;
            if(j - f[v] >= 0)   inf = min(inf,dp[j - f[v]] + x[v]);
            if(j - x[v] >= 0)   inf = min(inf,dp[j - x[v]] + f[v]);
            dp[j] = inf;
        }
    }
    for(int i = 0;i <= x[u];i++)
        f[u] = min(f[u],dp[i]);
}
int main()
{
    int n,pre;
    scanf("%d",&n);
    for(int i = 2;i <= n;i++)
        scanf("%d",&pre),edge[pre].push_back(i);
    for(int i = 1;i <= n;i++)
        scanf("%d",x+i);
    memset(f,0x3f,sizeof(f));
    dfs(1);
    if(f[1] >= 0x3f3f3f3f)
        puts("IMPOSSIBLE");
    else
        puts("POSSIBLE");
    return 0;
}


Measured memory_bytes: 640
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

s = input()
l = [0]*(len(s))
if s[0] == 'B':
    l[0] = 1
ans = 0
for i, c in enumerate(s[1:]):
    if c == 'B':
        l[i+1] = 1
    elif c == "W":
        ans += l[i]
    l[i+1] += l[i]
print(ans)


Measured memory_bytes: 11436
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()

    for i in range(1, 10):
        for j in range(1, 10):
            if i * j == N:
                print('Yes')
                exit()
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
using System;

public class AtCoder
{
    public static void Main()
    {
        string[] s;
        s = NextS();

        int n, h, w;
        n = int.Parse(s[0]);
        h = int.Parse(s[1]);
        w = int.Parse(s[2]);
        int ans = 0;
        for(int j=0; j<n; j++)
        {
            int[] a = new int[2];
            s = NextS();
            for (int i = 0; i < 2; i++) a[i] = int.Parse(s[i]);
            if (a[0] >= h && a[1] >= w) ans++;

        }
        

        Console.WriteLine(ans);
    }

    static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
    static string[] NextS() { return Console.ReadLine().Trim().Split(' '); }
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

const int INF = 1e9;

struct R {
    int h1, w1, h2, w2;
    R() : h1(INF), w1(INF), h2(-INF), w2(-INF) {}
    void update(int h, int w) {
        h1 = min(h1, h);
        w1 = min(w1, w);
        h2 = max(h2, h);
        w2 = max(w2, w);
    }
    void print() {
        cout << h1 << " " << w1 << " " << h2 << " " << w2 << endl;
    }
};

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

    int T;
    cin >> T;
    rep(testcase, T) {
        // cout << endl;
        // cout << "case " << testcase << ":" << endl;

        int H, W;
        cin >> H >> W;
        vector<string> s(H);
        set<char> itemset;
        rep(i, H) {
            cin >> s[i];
            rep(j, W) {
                if (s[i][j] != '.') {
                    itemset.insert(s[i][j]);
                }
            }
        }

        // rep(i, H) cout << s[i] << endl;
        // cout << endl;

        if (itemset.empty()) {
            cout << "SAFE" << endl;
            continue;
        }

        map<char, R> mprect;
        for (auto c : itemset) {
            R r;
            rep(i, H) rep(j, W) {
                if (s[i][j] == c) {
                    r.update(i, j);
                }
            }
            mprect[c] = r;
        }

        // for (auto p : mprect) {
        //     cout << p.first << ":";
        //     p.second.print();
        // }

        vector<char> items(all(itemset));

        auto check = [&]{
            sort(all(items));
            do {
                vector<string> t(H, string(W, '.'));

                for (auto c : items) {
                    auto r = mprect[c];
                    rep2(i, r.h1, r.h2 + 1) rep2(j, r.w1, r.w2 + 1) {
                        t[i][j] = c;
                    }
                }

                // rep(i, H) cout << t[i] << endl;
                // cout << endl;

                if (s == t) {
                    cout << "SAFE" << endl;
                    return true;
                }
            } while (next_permutation(all(items)));
            return false;
        };

        if (!check()) {
            cout << "SUSPICIOUS" << endl;
        }

    }

}

Measured memory_bytes: 3140
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, a, b) for(long long i = a; i < b; i++)
#define ll long long
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<ll> v(10000, 0);
  rep(x, 1, 101) {
    rep(y, 1, 101) {
      rep(z, 1, 101) {
        if(x*x + y*y + z*z + x*y + y*z + z*x <= 10000) {
          v[x*x + y*y + z*z + x*y + y*z + z*x]++;
        }
      }
    }
  }
  rep(i, 1, n+1) {
    cout << v[i] << "\n";
  }
}


Measured memory_bytes: 3576
#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 int inf=1e9+7;
const ll INF=1e18;

vin solve(int y,int t,int fif,int h,int fiv){
    vin ans(4,0);
    ans[0]=t;ans[1]=fif;ans[2]=h;ans[3]=fiv;
    int r=10*t+50*fif+100*h+500*fiv-y;
    ans[3]-=r/500;r-=(r/500)*500;
    ans[2]-=r/100;r-=(r/100)*100;
    ans[1]-=r/50;r-=(r/50)*50;
    ans[0]-=r/10;
    return ans;
}

int main(){
    queue<vin> q;
    while(1){
        int yen,ten,fifty,hund,fivehund;
        cin>>yen;
        if(yen==0)break;
        cin>>ten>>fifty>>hund>>fivehund;
        q.push(solve(yen,ten,fifty,hund,fivehund));
    }
    while(q.size()){
        auto p=q.front();q.pop();
        if(p[0]>0)cout<<10<<" "<<p[0]<<endl;
        if(p[1]>0)cout<<50<<" "<<p[1]<<endl;
        if(p[2]>0)cout<<100<<" "<<p[2]<<endl;
        if(p[3]>0)cout<<500<<" "<<p[3]<<endl;
        if(q.size())cout<<endl;
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int x; cin >> x;
    if(x < 100){
        cout << 0 << endl;
        return 0;
    }
    int a = x / 100;
    int A = x % 100;
    int j = A % 5;
    int cnt = A / 5;
    if(j == 0){
        if(cnt <= a){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }else{
        if(cnt < a){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 256
import sys
def t(A,p,r):
 x=A[r][1];i=p-1
 for j in range(p,r):
  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
def k(A,p,r):
 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)
def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1][1]>=l[1]:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):l=len(A);s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
input()
f=lambda x,y:(x,int(y))
A=[f(*e.split())for e in sys.stdin]
B=A[:]
k(A,0,len(A)-1)
print(['Not s','S'][A==d(B)]+'table')
for e in A:print(*e)


Measured memory_bytes: 20172
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
struct Node {
    int key;
    Node *prev, *next;
};

Node *nil;

void init( ) {
    nil = (Node*) malloc(sizeof(Node));
    nil->prev = nil;
    nil->next = nil;
}

void myInsert( int key ) {
    Node *x = (Node*) malloc(sizeof(Node));
    x->key = key;

    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node* nodeSerach( int key ) {
    Node *cur = nil->next;
    while ( cur != nil && cur->key != key ) {
        cur = cur -> next;
    }
    return cur;
}

void delNode( Node *t ) {
    if( t == nil ) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void delFirst( ) {
    delNode( nil->next );
}

void delLast( ) {
    delNode( nil->prev );
}

void delKey( int key ) {
    Node *t = nil->next;
    delNode( nodeSerach( key ) );
}

void printList( ) {
    Node *t = nil->next;
    int f = 0;
    while( t != nil ) {
        if( f ) printf(" ");
        printf("%d", t->key); f = 1;
        t = t->next;
    }
    printf("\n");
}

char cmd[20];

int main( ) {
    int key, n;
    init();
    scanf("%d", &n);
    getchar();
    while ( n-- ) {
        scanf("%s", cmd);
        if ( !strcmp(cmd, "insert") ) {
            scanf("%d", &key); getchar();
            myInsert(key);
        }
        if ( !strcmp(cmd, "delete") ) {
            scanf("%d", &key); getchar();
            delKey(key);
        }
        if ( !strcmp(cmd, "deleteFirst") ) delFirst( );
        if ( !strcmp(cmd, "deleteLast") ) delLast( );
    }
    printList();
    return 0;
}



Measured memory_bytes: 34456
N,Y = map(int,input().split())

ho = 10000 * N - Y
x = y = z = -1
for i in range(N + 1):
    for j in range(N + 1 - i):
        if(ho == 5000 * i + 9000 * j):
            y = i
            z = j
            x = N - i - j
            break

print(x,y,z)

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var str string
	_, _ = fmt.Scan(&str)
	n := len(str) - 1
	for i := 0; i < 1 << uint(n); i++ {
		total, _ := strconv.Atoi(string(str[0]))
		formula := string(str[0])
		for j := 0; j < n; j++ {
			tmp1, _ := strconv.Atoi(string(str[j + 1]))
			tmp2 := string(str[j + 1])
			if 1 & (uint(i) >> uint(j)) == 1 {
				total += tmp1
				formula += "+" + tmp2
			} else {
				total -= tmp1
				formula += "-" + tmp2
			}
		}
		if total == 7 {
			fmt.Println(formula + "=7")
			return
		}
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>

using namespace std;

int main() {
    cout << fixed << setprecision(10);
    
    int n, k;
    cin >> n >> k;
    
    int cnt = 0;
    for (int idx = 0; idx < n; idx++) {
        int tmp = 0;
        cin >> tmp;
        if (tmp >= k) {
            cnt++;
        }
    }
    
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int sx=nxt(),sy=nxt(),tx=nxt(),ty=nxt();

    string test="";
    for(int i=0;i<tx-sx;i++)
        test+="R";
    for(int i=0;i<ty-sy;i++)
        test+="U";
    for(int i=0;i<tx-sx;i++)
        test+="L";
    for(int i=0;i<ty-sy;i++)
        test+="D";
    test+="D";
    for(int i=0;i<tx-sx+1;i++)
        test+="R";
    for(int i=0;i<ty-sy+1;i++)
        test+="U";
    test+="L";
    test+="U";
    for(int i=0;i<tx-sx+1;i++)
        test+="L";
    for(int i=0;i<ty-sy+1;i++)
        test+="D";
    test+="R";
    cout<<test<<endl;


    
    
    return 0;   
}




 
 


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

int main()
{
        int d[50 + 5] = {};
        int n;
        cin >> n;
        for (int i = 0; i < n; ++i)
                cin >> d[i];

        int ans = 0;
        for (int i = 0; i < n; ++i)
                for (int j = i + 1; j < n; ++j)
                        ans += d[i] * d[j];
        cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)  cin>>a[i];
    for(int i=0; i<n; i++){
        int v=a[i];
        int j=i-1;
        while(j>=0 && v<a[j]){
            a[j+1] = a[j];
            j--;
        }
        a[j+1]=v;
        for(int k=0; k<n-1; k++) cout<<a[k]<<" ";
        cout<<a[n-1]<<endl;
    }
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m; cin >> n >> m;
	vi v(n + 1), h(n + 1);
	vi t(m), s(m);
	rep(i, n) cin >> v[i + 1] >> h[i + 1];
	rep(i, m) cin >> t[i] >> s[i];
	
	vi dh(n);
	rep(i, n - 1) dh[i + 1] = dh[i] + abs(h[i + 2] - h[i + 1]);
	rep(i, n) v[i + 1] += v[i];
	rep(i, n) h[i + 1] += h[i];
	
	vector<vi> dp(m + 1, vi(n + 1, -1));
	vector<vi> cost(n + 1, vi(n + 1, -inf));
	
	rep(i, n + 1) for(int j = i; j <= n; j++){
		int x = h[j] - h[i];
		if(i < j) x += dh[j - 1] - dh[i];
		cost[i][j] = x;
	}
	
	vi L(m + 1), R(m + 1, -1);
	R[0] = 0;
	dp[0][0] = 0;
	
	rep(i, m){
		int nL = n + 1, nR = -1;
		dp[i + 1] = dp[i];
		
		for(int j = L[i]; j <= R[i]; j++){
			
			int l = j - 1, r = n, mid;
			if(dp[i][j] + cost[j][n] < s[i]) continue;
			while(l + 1 < r){
				mid = (l + r) / 2;
				if(dp[i][j] + cost[j][mid] < s[i]) l = mid;
				else r = mid;
			}
			nL = min(nL, r);
			nR = max(nR, r);
			
			if(i && dp[i - 1][j] == dp[i][j] && L[i - 1] <= j && j <= R[i - 1])
				r = R[i] + 1;
			
			for(int k = r; k <= n && v[k] <= t[i]; k++){
				int str = dp[i][j] + cost[j][k];
				nR = max(nR, k);
				dp[i + 1][k] = max(dp[i + 1][k], str);
			}
		}
		L[i + 1] = nL; R[i + 1] = nR;
	}
	//rep(i, m + 1) dbg(i, dp[i]);
	
	int ans = -1;
	for(int i = L[m]; i <= R[m]; i++) if(dp[m][i] >= 0){
		ans = i;
		break;
	}
	if(ans < 0) cout << -1 << endl;
	else cout << t[m - 1] - v[ans] << endl;
	return 0;
}


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

#define MAX(p,q) ((p>q)?(p):(q))
#define MIN(p,q) ((p<q)?(p):(q))

#define INF 1000000000;
#define REP(i,n) for(i=0;i<n;i++)

int gcd(int a,int b);
/*比較函数の実装
int -32768 to 32767 (2**15-1)
long -2147483648 to 2147483648 (2**31-1)
*/
int intcmp(const void *a,const void *b){
  return *(int *)a - *(int *)b;
}
//qsort(a,sizeof(a)/sizeof(int),sizeof(int),intcmp);
int longcmp(const void *a,const void *b){
  return *(long *)a - *(long *)b;
}
//qsort(a,sizeof(a)/sizeof(long),sizeof(long),longcmp);
int doublecmp(const void *a, const void *b){
  return *(double *)a - *(double *)b;
}
//qsort(a,sizeof(a)/sizeof(double),sizeof(double),doublecmp);
int main(void)
{
  int n;
  scanf("%d",&n);
  int i;
  int w[99] = {0};
  int sw[99] = {0};
  REP(i,n){
    scanf("%d",&w[i]);
    if(i==0) sw[0] = w[0];
    else sw[i] += (w[i]+sw[i-1]);
   // printf("%d\n",sw[i]);
  }
  int min = 100000;
  REP(i,n)
  {
  //  printf("%d",)
    if(min>fabs(sw[i]-(sw[n-1]-sw[i]))) min = fabs(sw[i]-(sw[n-1]-sw[i]));
  }
  printf("%d",min);
  return 0;
  
}

Measured memory_bytes: 128
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
bl = True
if S != S[::-1]:
    bl = False
N = len(S)
N = (N-1) // 2
if S[:N] != S[:N][::-1]:
    bl = False

print('Yes' if bl else 'No')


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const int MAXN=100;
const ll MOD=10;
ll _gcd(ll a,ll b){if(b==0)return a;return _gcd(b,a%b);}
ll gcd(ll a,ll b){a=abs(a),b=abs(b);if(a<b)swap(a,b);return _gcd(a,b);}
ll qpow(ll a,ll n){ll rt=1;while(n){if(n&1)rt=(rt*a)%MOD;a=a*a%MOD;n>>=1;}return rt;}
ll factor[MAXN];
void cal_factor(){factor[0]=1;for(int u=1;u<MAXN;u++){factor[u]=(factor[u-1]*u)%MOD;}}
ll C(ll n,ll k){return factor[n]*qpow(factor[n-k],MOD-2)%MOD*qpow(factor[k],MOD-2)%MOD;}
ll A[MAXN];
void solve(){
    int N;
    cin>>N;
    for(int u=0;u<N;u++)cin>>A[u];
    int money=1000;
    int hd=0;
    while(hd<N){
        while(hd+1<N&&A[hd+1]<A[hd]){
            hd++;
        }
        int tl=hd;
        while(tl+1<N&&A[tl+1]>A[tl]){
            tl++;
        }
        money=money/A[hd]*A[tl]+money%A[hd];
        hd=tl+1;
    }
    cout<<money<<"\n";
}
void Ans(){
    int N;
    cin>>N;
    for(int u=0;u<N;u++)cin>>A[u];
    ll money=1000;
    for(int u=0;u<N;u++){
        if(A[u+1]>A[u]){
            money+=money/A[u]*(A[u+1]-A[u]);
        }
    }
    cout<<money<<"\n";
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    Ans();
}

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

int main(){
    
    ll a,v,b,w,t; cin >> a >> v >> b >> w >> t;
    if(a < b) cout << (a+v*t >= b+w*t ?"YES":"NO") << endl;
    else cout << (a-v*t<=b-w*t ?"YES":"NO") << endl;
    
    
}


Measured memory_bytes: 3640
def dfs_grid(h,w,sy, sx, maze,visited):
    cur = defaultdict(int)
    def bfs(cur):
        queue = []
        queue.insert(0, (sy, sx))
        visited[sy][sx] = True
        cur[maze[sy][sx]] += 1
        while len(queue):
            y, x = queue.pop()
            now = maze[y][x]
            for i in range(0, 4):
                nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]
                if (0<= nx <w and 0<= ny <h and maze[ny][nx] != now and (not visited[ny][nx])):
                    queue.insert(0, (ny, nx))
                    visited[ny][nx] = True
                    cur[maze[ny][nx]] +=1
        return cur
    return bfs(cur)
def examC():
    H, W = LI()
    S = [SI() for _ in range(H)]
    ans = 0
    visited = [[False]*(W) for _ in range(H)]
    for i in range(H):
        for j in range(W):
            d = dfs_grid(H,W,i,j,S,visited)
            ans += d["."]*d["#"]
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()


Measured memory_bytes: 5104
import qualified Data.IntMap as M

main :: IO ()
main = do
    [_, m] <- readInts
    as <- readInts
    print $ solve m as

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve :: Int -> [Int] -> Int
solve m =  M.foldr (\x y -> (x * (x - 1) `div` 2) + y) 0
     . foldr (M.alter $ return . maybe 1 succ)  M.empty
     . map (`mod` m)
     . scanr (+) 0


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

#define int long long

signed main(){

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> a[i];
    
    sort(a.begin(), a.end());

    bool isplus[100010];
    isplus[0] = false;
    isplus[n-1] = true;
    for (int i = 1; i < n-1; ++i)
    {
        isplus[i] = (a[i] > 0);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        if(isplus[i]){
            ans += a[i];
        }
        else{
            ans -= a[i];
        }
    }
    cout << ans << endl;
    
    int now = a[0];
    for (int i = 1; i < n-1; ++i)
    {
        if(isplus[i]){
            cout << now << " " << a[i] << endl;
            now -= a[i];
        }
    }
    
    int now2 = a[n-1];
    for (int i = 1; i < n-1; ++i)
    {
        if(!isplus[i]){
            cout << now2 << " " << a[i] << endl;
            now2 -= a[i];
        }
    }    
    cout << now2 << " " << now << endl;

    return 0;
}

Measured memory_bytes: 2816
N, M = map(int, input().split())
L1, R1 = map(int, input().split())
flag = 0
def find_key(L1,R1,L2,R2):
    if R1 < L2 or R2 < L1:
        return(False)
    else:
        a = [R1,L1,R2,L2]
        a.sort()
        return(a[1],a[2])

for i in range(M - 1):
    L,R = map(int, input().split())
    if find_key(L1,R1,L,R) != False:
        L1,R1 = find_key(L1,R1,L,R)
    else:
        flag = 1
        print(0)
        break
if flag == 0:
    print(R1-L1+1)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
// #include <bits/stdc++.h>

using namespace std;
typedef long long li;

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

    string back = s.substr(n);
    li ans = 0;
    for (int mask = 0; mask < (1 << n); ++mask) {
        string red, blue;
        for (int i = 0; i < n; ++i) {
            if ((mask >> i) & 1) {
                red.push_back(s[i]);
            } else {
                blue.push_back(s[i]);
            }
        }
        reverse(red.begin(), red.end());
        reverse(blue.begin(), blue.end());
        vector<vector<li>> dp(n + 1, vector<li>(n + 1, 0));
        dp[0][0] = 1;
        for (int r = 0; r <= red.size(); ++r) {
            for (int b = 0; b <= blue.size(); ++b) {
                if (r + b == 0) {
                    continue;
                }
                char c = back[r + b - 1];
                if (r > 0 && red[r - 1] == c) {
                    dp[r][b] += dp[r - 1][b];
                }
                if (b > 0 && blue[b - 1] == c) {
                    dp[r][b] += dp[r][b - 1];
                }
            }
        }
        ans += dp[red.size()][blue.size()];
    }

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


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

bool mp[8][8];


void Bomb(int x, int y){

  mp[y][x] = false;

  for(int i=1; i<=3; i++){

    if(x-i>=0 && mp[y][x-i]==true)Bomb(x-i,y);
    if(x+i< 8 && mp[y][x+i]==true)Bomb(x+i,y);
    if(y-i>=0 && mp[y-i][x]==true)Bomb(x,y-i);
    if(y+i< 8 && mp[y+i][x]==true)Bomb(x,y+i);

  } 

}


int main(){

  int n;
  int fx,fy;
  char c;

  cin >> n;

  for(int i=0; i<n; i++){

    for(int j=0; j<8; j++)for(int k=0; k<8; k++){cin>>c;mp[j][k]=c-'0';}

    cin >> fx>>fy;
    fx--; fy--;

    Bomb(fx,fy);

    cout << "Data " << i+1 << ':' << endl;
    for(int j=0; j<8; j++){
      for(int k=0; k<8; k++){
	cout << mp[j][k];
      }
      cout << endl;
    }

  }


  return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <iostream>
#include <array>
#include <vector>
#include <cmath>
using namespace std;
 
const int D=200;
const int N=200;
 
struct Clothes{
    int max_t;
    int min_t;
    int c;
};
 
int main(){
    int d,n;
    array<array<int,N>,D> dp;
    vector<Clothes> clt;
    vector<int> tmp;
 
    cin>>d>>n;
 
    tmp.resize(d);
 
    for( auto &t : tmp ) cin>>t;
 
    clt.resize(n);
 
    for( auto &t : clt ) cin>>t.min_t>>t.max_t>>t.c;
 
    for( auto &x : dp ){
        for( auto &y : x ){
            y=0;
        }
    }
 
    for( int i=1 ; i<d ; i++ ){
        for( int j=0 ; j<n ; j++ ){
            if( tmp[i] >= clt[j].min_t && tmp[i] <= clt[j].max_t ){
                for( int k=0 ; k<n ; k++){
                    if( tmp[i-1] >= clt[k].min_t && tmp[i-1] <= clt[k].max_t ){
                        dp[i][j]=max(dp[i][j],abs(clt[j].c-clt[k].c)+dp[i-1][k]);
                    }
                }
            }
        }
    }
 
    cout << accumulate(dp[d-1].begin(),dp[d-1].begin()+n,0,[](int a,int b){ return ( a>b ? a : b ); }) <<endl;
 
    return 0;
}

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

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

using namespace std;

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

	bool flag = false;
	for(int i = 1; i <= 9; ++i){
		if(n % i == 0 && n / i <= 9) {
			flag = true;
			break;
		}
		else continue;
	}

	if(flag) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 256
var n,m,c,i,j,sum,a,ans :integer;
    b:array[1..30] of integer;
begin
  readln(n,m,c);
  ans:=0;
  for i:=1 to m do read(b[i]);
  readln;
  for i:=1 to n do begin
    sum:=c;
    for j:=1 to m do begin
      read(a);
      sum:=sum+a*b[j];
    end;
    readln;
    if sum>0 then ans:=ans+1
  end;
  write(ans);
  end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e-9
#define HH1 402653189
#define HH2 1610612741

int n, a[105], sum;

int main () {
	
	scanf("%d", &n);
	
	FOR(i, 0, n) scanf("%d", a + i);
	
	FOR(i, 0, n) sum += a[i];
	
	if (sum % 10 != 0) return 0 * printf("%d\n", sum);
	
	int mn = sum;
	
	FOR(i, 0, n) if (a[i] % 10 != 0) mn = min(mn, a[i]);
	
	printf("%d\n", sum - mn);
	
	return 0;
	
}

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

void Insertion_Sort(int N,int A[]){
  int v;
  for(int i=1;i<N;i++){
    v = A[i];
    int j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for(int k=0;k<N;k++){
          if(k ==0){
              cout << A[k];
          }else{
              cout << " " << A[k];
          }
      }
      cout << endl;
  }

}


int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  for(int k=0;k<N;k++){
        if(k ==0){
            cout << A[k];
        }else{
            cout << " " << A[k];
        }
    }
    cout << endl;
  Insertion_Sort(N,A);
}



Measured memory_bytes: 3092
# -*- coding: utf-8 -*-
import sys
#全体の最頻値が奇数のみ or 偶数のみの最頻値とは限らない！
def get_sorted_num(v):
	num_v = {}
	for v_ in v:
		if v_ not in num_v:
			num_v[v_]  = 1
		else:
			num_v[v_] += 1
	sorted_num_v = sorted(num_v.items(), key=lambda x:x[1])
	return sorted_num_v

n = input()
v = map(int, raw_input().split())

if len(get_sorted_num(v)) == 1:
	print n / 2
	sys.exit()

sorted_num_odd = get_sorted_num(v[0::2])
sorted_num_even = get_sorted_num(v[1::2])

odd_1st_k, odd_1st_v = sorted_num_odd[-1]
even_1st_k, even_1st_v = sorted_num_even[-1]

	
if odd_1st_k == even_1st_k:
	if len(sorted_num_odd) == 1:
		print len(v[0::2]) - odd_1st_v + len(v[1::2]) - even_2nd_v
	elif len(sorted_num_even) == 1:
		print len(v[0::2]) - odd_2nd_v + len(v[1::2]) - even_1st_v
	else:
		odd_2nd_k, odd_2nd_v = sorted_num_odd[-2]
		even_2nd_k, even_2nd_v = sorted_num_even[-2]
		if odd_2nd_v > even_2nd_v:
			print len(v[0::2]) - odd_2nd_v + len(v[1::2]) - even_1st_v
		else:
			print len(v[0::2]) - odd_1st_v + len(v[1::2]) - even_2nd_v
else:
	print len(v[0::2]) - odd_1st_v + len(v[1::2]) - even_1st_v
	



Measured memory_bytes: 23772
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    string s;
    ll k;
    cin >>s>>k;

    ll len(0);

    set<string> ss;

    rep(i,0,s.size()+1)
    {
        rep(j,0,k+1)
            ss.insert(s.substr(i,j));
    }

    ll m(0);
    for (auto i: ss)
    {
        if (m==k)
        cout << i << endl;
        ++m;
    }

    return 0;
}


Measured memory_bytes: 1664
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, h, m float64
	fmt.Scan(&a, &b, &h, &m)

	hourDeg := (h*60 + m) / 2
	minDeg := m * 6

	deg := minDeg - hourDeg
	if deg < 0 {
		deg = -deg
	}
	if deg >= 180 {
		deg = 360 - deg
	}

	rad := (math.Pi / 180) * deg
	cc := (a * a) + (b * b) - 2*a*b*math.Cos(rad)
	fmt.Println(math.Sqrt(cc))
}

Measured memory_bytes: 1820
for i in range(10000):
    H,W=input().split()
    if H=="0" and W=="0":
        break
    s=""
    t=""
    for j in range(int(W)):
        s+="#"
        if j==0 or j==int(W)-1:
            t+="#"
        else:
            t+="."
    for k in range(int(H)):
        if k==0 or k==int(H)-1:
            print(s)
        else:
            print(t)
    print("")


Measured memory_bytes: 5612
//by achhhy
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PII;
inline int in()
{
	char ch=getchar();
	int f=1,x=0;
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return f*x;
}
//need changing
const int inf=(1<<30);
const int mod=1e9+7;
const int N=300010;

int n,m,a[N],b[N];
char s[N];

int main()
{
	n=in();
	scanf("%s",s+1);
	rep(i,1,n)
	{
		a[i]=a[i-1]+(s[i]=='E');
		b[i]=b[i-1]+(s[i]=='W');
	}
	int ans=inf;
	rep(i,1,n)
	{
		ans=min(ans,b[i-1]+a[n]-a[i]);
	}
	cout<<ans<<endl;
	return 0;
}




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


int main() {
	int a, b;
	cin >> a >> b;

	if (a == b) {
		cout << "Draw" << endl;
	}
	else if (a == 1) {
		cout << "Alice" << endl;
	}
	else if (b == 1) {
		cout << "Bob" << endl;
	}
	else if (a > b) {
		cout << "Alice" << endl;
	}
	else if (a < b) {
		cout << "Bob" << endl;
	}
}

Measured memory_bytes: 384
H, W = map(int, input().split())
s = []
for _ in range(H):
    s.append(input())
    
Flg = "Yes"
for i in range(H):
    for j in range(W):
        if(s[i][j] == '#'):
            if(s[i][max(j-1, 0)] == "." and s[i][min(j+1, W-1)] == '.' and s[min(i+1, H-1)][j] == '.' and s[max(i-1, 0)][j] == '.'):
                Flg = "No"

print(Flg)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define ll long long int

int main() {
	ll d,t,s;
	cin >> d >> t >> s;
	
	if(d > t*s){
		cout << "No";
	}
	else{
		cout << "Yes";
	}
	
	
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int N=1000;

int LCS(string x,string y){
	int c[N+1][N+1],LCSlen=0;
	int m=x.size();
	int n=y.size();
	x=' '+x;
	y=' '+y;
	for(int i=1;i<=m;i++) c[i][0]=0;
	for(int j=1;j<=n;j++) c[0][j]=0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(x[i]==y[j])
			c[i][j]=c[i-1][j-1]+1;
			else
			c[i][j]=max(c[i][j-1],c[i-1][j]);
			LCSlen=max(LCSlen,c[i][j]);
		}
	}
	return LCSlen;
}

int main(){
	string x,y;
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin>>x;
		cin>>y;
		printf("%d\n",LCS(x,y));
	}
}

Measured memory_bytes: 7124