akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

long long nCkmod(long long n, long long k) {
    long long denomi = 1;
    REP(i, n) {
        denomi *= (i + 1);
        denomi %= mod;
    }
    long long numera = 1;
    for (int i = n - k; i > 0; i--) {
        numera *= i;
        numera %= mod;
    }
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
int main() {
    char a;
    cin >> a;
    if (a < 95) {
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }
}

Measured memory_bytes: 3640
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        long mod=1000000007;
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        PriorityQueue<Integer> q=new PriorityQueue<>();
        
        int n=sc.nextInt();

        for (int i = 1; i < 10; i++) {
            for (int t = 1; t < 10; t++) {
            	if(t*i==n)ret("Yes");
            }
		}


        out.println("No");
     	out.flush();
    }
    
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}


class P {
	int x, y, d;
	P(int  x, int y, int d) {
	  this.x=x;
	  this.y=y;
	  this.d=d;
	}
}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//        return p.a-a;//des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() throws IOException{
        return this.nextString().toCharArray();
    }    
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 23380
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextInt();
		Long m = sc.nextLong();
		Map<Long, List<Long>> map = new HashMap<>();
		while (sc.hasNextLong()) {
			Long a = sc.nextLong(); // a日後
			Long b = sc.nextLong(); // 報酬
			Long key = m - a;
			if (key < 0) {
				continue;
			}
			List<Long> list = map.getOrDefault(key, new ArrayList<Long>());
			list.add(b);
			map.put(key, list);
		}

		// 日数ごとにバイトの報酬順でのソート

		long sum = 0;
		Queue<Long> queue = new PriorityQueue<Long>(Collections.reverseOrder());
		for (long i = m - 1; i >= 0; i--) {
			try {
				queue.addAll(map.get(i));
			} catch (Exception e) {}
			if(queue.isEmpty()) {
				continue;
			}
			sum = sum + queue.poll();
		}
		sc.close();
		System.out.println(sum);
	}
}


Measured memory_bytes: 106964
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <cstdlib>

using namespace std;

class SleepingCats
{
private:
  vector<int> cats;
  int m_length;
public:
  SleepingCats(int length) : m_length(length), cats(length, -1)
  {
  }
  
  ~SleepingCats()
  {
  }

  int sleep(int cat_id, int cat_width)
  {
    for (int i = 0; i <= m_length - cat_width; i++) {
      bool canCatSleep = true;
      for (int j = i; j < i + cat_width; j++) {
        if (cats[j] != -1) {
          canCatSleep = false;
          break;
        }
      }
      if (canCatSleep == true) {
        for (int j = i; j < i + cat_width; j++) {
          cats[j] = cat_id;
        }
        return i;
      }
    }
    return -1;
  }

  void wakeup(int cat_id)
  {
    for (int i = 0; i < m_length; i++) {
      if (cats[i] == cat_id) {
        cats[i] = -1;
      }
    }
  }
};

int main()
{
  int w, q;
  string line, str;
  vector<string> v;
  
  while (cin >> w >> q) {
    cin.ignore();
    if (w == 0 && q == 0) return 0;
    
    SleepingCats sleepingCats(w);

    for (int i = 0; i < q; i++) {
      v.clear();
      getline(cin, line, '\n');
      stringstream ss(line);
      while (getline(ss, str, ' ')) {
        v.push_back(str);
      }
      if (v[0] == "s") {
        int ret = sleepingCats.sleep(atoi(v[1].c_str()), atoi(v[2].c_str()));
        if (ret == -1) {
          cout << "impossible" << endl;
        } else {
          cout << ret << endl;
        }
      } else {
        sleepingCats.wakeup(atoi(v[1].c_str()));
      }
    }
    cout << "END" << endl;
  } 
}



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

int main(){
  int N,T;
  cin>>N>>T;
  vector<int> t(N);
  for(int i=0;i<N;i++){
    cin>>t.at(i);
  }
  
  long long sum=0;
  int s,e;
  s=0;
  e=T;
  for(int i=0;i<N;i++){
    if(t.at(i)>e){
      sum+=e-s;
      s=t.at(i);
    }
    e=t.at(i)+T;
  }
  sum+=e-s;
  cout<<sum<<endl;
}

Measured memory_bytes: 1024
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    #n = int(stdin.readline().rstrip())
    A, B = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    print(A*B)

main()


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

using lnt = long long;
template <class T> using SET = unordered_set<T>;
template <class T, class S> using MAP = unordered_map<T, S>;

#define REP(i, n) for (lnt i = 0; i < (n); i++)
#define FOR(i, a, b) for (lnt i = (a); i < (b); i++)
#define ALL(a) a.begin(), a.end()
#define BIT(i) POW(2, i)
#define INF (2 * POW(10, 18)) // cf. LLONG_MAX ≒ 9x10^18

#define MAXELM max_element
#define MINELM min_element
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define PB push_back

#define MAIN int main
#define ABS abs<lnt>
#define MAX max<lnt>
#define MIN min<lnt>

lnt inline POW(const lnt x, const lnt y) {
  lnt init = 1;
  for (lnt i = 0; i < y; i++) {
    init *= x;
  }
  return init;
}

template <class T, class S>
lnt inline CNT(const T &iteraterFirst, const T &iteraterLast, const S &value) {
  return (lnt)count(iteraterFirst, iteraterLast, value);
}

template <class T>
lnt inline DIST(const T &iteraterFirst, const T &iteraterLast) {
  return (lnt)distance(iteraterFirst, iteraterLast);
}

template <class T> lnt inline SIZE(const T &sequence) {
  return (lnt)(sequence.size());
}

MAIN() {
  lnt n, m;
  cin >> n >> m;
  vector<pair<pair<lnt, lnt>, lnt>> vcTr;
  REP(city, m) {
    lnt a, b;
    cin >> a >> b;
    vcTr.PB(pair<pair<lnt, lnt>, lnt>(pair<lnt, lnt>(a, b), city));
  }

  sort(ALL(vcTr));
  vector<lnt> p, vcCity;
  REP(i, m) {
    p.PB(vcTr[i].F.F);
    vcCity.PB(vcTr[i].S);
  }

  vector<string> vcPrefIndexedByCity(m), vcOrderIndexedByCity(m);
  FOR(pref, 1, n + 1) {
    lnt indexBegin = DIST(p.begin(), LB(ALL(p), pref)),
        indexEnd = DIST(p.begin(), UB(ALL(p), pref));
    FOR(i, indexBegin, indexEnd) {
      lnt order = i - indexBegin + 1;
      string szPref = to_string(pref), szOrder = to_string(order);
      lnt sizePref = SIZE(szPref), sizeOrder = SIZE(szOrder);
      REP(j, 6 - sizePref) { szPref.insert(szPref.begin(), '0'); }
      REP(j, 6 - sizeOrder) { szOrder.insert(szOrder.begin(), '0'); }
      vcPrefIndexedByCity[vcCity[i]] = szPref;
      vcOrderIndexedByCity[vcCity[i]] = szOrder;
    }
  }

  REP(city, m) {
    REP(j, 6) { cout << vcPrefIndexedByCity[city][j]; }
    REP(j, 6) { cout << vcOrderIndexedByCity[city][j]; }
    cout << endl;
  }
}


Measured memory_bytes: 17136
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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


int main() {
	ll n; cin >> n;
	vector<pair<ll,ll>> a(n);
	rep(i,n) { cin >> a[i].first; a[i].second = i;}

	sort(all(a), greater<pair<ll,ll>>());

	vector<vector<ll>> dp(n+1, vector<ll>(n+1,0));

	rep1(k, n) rep(i, n+1) {
	  int j = k - i;
	  if (0 <= i-1 && 0 <= j && j <= n) chmax(dp[i][j], dp[i-1][j] + a[k-1].first*(a[k-1].second-i+1));
		if (0 <= j-1 && j <= n) chmax(dp[i][j], dp[i][j-1] + a[k - 1].first * (n-j - a[k-1].second));
	}

	ll ans = 0;
	rep(i,n+1) chmax(ans, dp[i][n-i]);
	cout << ans << endl;
}

Measured memory_bytes: 34620
#include<bits/stdc++.h>
#define ll      long long int
#define nl      '\n'
using namespace std;

int main(void){

    int n,m,ans=0;
        cin>>n;

    vector<ll>a(n+5);

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

    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            ans +=a[i]*a[j];
        }
    }
    cout<<ans;
}



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

int main() {
  int n;
  cin >> n;
  int F[50];
  F[0] = F[1] = 1;
  for (int i = 2; i <= n; i++) F[i] = F[i - 1] + F[i - 2];
  cout << F[n] << endl;
};



Measured memory_bytes: 3092
let a, b, c = Scanf.scanf "%d %d %d\n" (fun a b c -> a, b, c)
module IntSet =
  Set.Make (struct
    type t = int
    let compare i j = i - j
  end)

open IntSet

let set = add a (add b (add c empty))

let () = print_int @@ List.length (elements set);
  print_newline ()


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

P<ll,ll> Cut(ll h,ll w){
  ll half_h = h/2, half_w = w/2;
  ll cut1a = half_h * w;  
  ll cut1b = (h-half_h) * w;  
  ll cut2a = half_w * h;  
  ll cut2b = (w-half_w) * h;
  if(cut1a > cut2a) return {cut1a,cut1b};
  return {cut2a,cut2b};
}

int main(){
  ll h,w; cin >> h >> w;
  ll ans = 1001001001001;
  for(ll i = 0; i <= h; ++i){
    ll a = w * i;
    ll b,c;
    tie(b,c) = Cut(h-i,w);
    // debug(i);
    // debug(a);
    // debug(b);
    // debug(c);
    ChangeMin(ans,max({a,b,c}) - min({a,b,c}));
  }
  for(ll i = 0; i <= w; ++i){
    ll a = h * i;
    ll b,c;
    tie(b,c) = Cut(h,w-i);
    ChangeMin(ans,max({a,b,c}) - min({a,b,c}));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    long[][] dp = new long[N][N];
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < N; j++) {
        if(i != j) dp[i][j] = Integer.MAX_VALUE;
      }
    }
    ArrayList<Edge> edgeList = new ArrayList<Edge>();
    for(int i = 0; i < M; i++) {
      int a = sc.nextInt() - 1;
      int b = sc.nextInt() - 1;
      long c = sc.nextLong();
      dp[a][b] = c;
      dp[b][a] = c;
      edgeList.add(new Edge(a, b, c));
    }
    // ワーシャル・フロイド
    for(int k = 1; k <= N; k++) {
      for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
          dp[i][j] = Math.min(dp[i][j], dp[i][k - 1] + dp[k - 1][j]);
        }
      }
    }
    int ans = 0;
    for(int i = 0; i < M; i++) {
      Edge e = edgeList.get(i);
      if(dp[e.u][e.v] < e.cost) ans++;
    }
    System.out.println(ans);
  }
}

class Edge {
  int u;
  int v;
  long cost;

  Edge(int u, int v, long cost) {
    this.u = u;
    this.v = v;
    this.cost = cost;
  }
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl

typedef long long LL;
const int N = 200003;
int n;
string s;
int dp[2019], dp2[2019];
LL ans;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> s;
    n = s.length();
    
    for(int i = 0; i < n; ++i) {
        int dig = s[i] - '0';
        for(int num = 0; num < 2019; ++num) {
            int nxt = (num*10 + dig)%2019;
            dp2[nxt] += dp[num];
        }
        dp2[dig]++;
        ans += dp2[0];

        for(int i = 0; i < 2019; ++i) {
            dp[i] = dp2[i];
            dp2[i] = 0;
        }
    }

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


Measured memory_bytes: 3728
#include<bits/stdc++.h>
#define ll long long
#define MOD int(1e9+7)
#define mp make_pair
#define pb push_back
using namespace std;

vector<ll> dp(10001,INT_MAX);

int main()
{
    ll h,n;
    cin>>h>>n;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++) cin>>a[i]>>b[i];

    dp[0]=0;
    for(int i=1;i<=h;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(a[j]<=i)
            {
                dp[i]=min(dp[i],dp[i-a[j]]+b[j]);
            }
            else dp[i]=min(dp[i],b[j]);
        }
    }
    cout<<dp[h];
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int a;
    cin >> a;
    string s;
    cin >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)
const double pi = std::acos(-1);

int main(){
    double a,b,h,m;
    cin>>a>>b>>h>>m;

    double time=60*h+m;

    double rad_h,rad_m,rad_d;
    rad_h=time*1/360;
    rad_m=time*1/30;
    rad_d=abs(rad_h-rad_m);
    double l2=pow(a,2)+pow(b,2)-2*a*b*cos(rad_d*pi);

    cout<<fixed<<setprecision(20)<<sqrt(l2)<<endl;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;

const ll MOD = 2;

void solve()
{
  ll N;
  scanf("%lld",&N);
  vector<ll> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  ll ans=0;
  while(true) {
    for (int i=0; i<N; i++) {
      if (A[i]%2==1) {
        cout << ans << endl;
        return;
      }
      A[i]/=2;
    }
    ans++;
  }
}

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


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define clr(s, x) memset(s, x, sizeof(s))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
inline int read(){int r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll readll(){ll r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
inline ll gcd(ll a,ll b){while(b^=a^=b^=a%=b);return a;}
const double eps = 1e-8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 1e5;
const int MAXM = 1e5;
int dp[3005][3005];
int w[3005][3005];
char s1[3005],s2[3005];
void dfs(int l1,int l2){
	if(l1==0||l2==0) return ;
	if(s1[l1]==s2[l2]){
		dfs(l1-1,l2-1);
		cout<<s1[l1];
	}
	else if(dp[l1-1][l2]>dp[l1][l2-1]){
		dfs(l1-1,l2);
	}
	else dfs(l1,l2-1);
}
int main(){
	scanf("%s",(s1+1));
	scanf("%s",(s2+1));
	int l1=strlen(s1+1);int l2 = strlen(s2+1);
	memset(w,0,sizeof(w)); 
	dp[0][0]=0;
	for(int i=1;i<=l1;i++){
		for(int j=1;j<=l2;j++){
			if(s1[i]==s2[j]){
				 dp[i][j]=dp[i-1][j-1]+1;
			}
			else{
				if(dp[i-1][j]>=dp[i][j-1]){
					dp[i][j]=dp[i-1][j];
				}
				else{
					dp[i][j]=dp[i][j-1];
				}
			}
		}
	}
	dfs(l1,l2);
	puts("");
	return 0;
}


Measured memory_bytes: 71040
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m,c;
    cin>>n>>m>>c;
    int ans=0;
    vi b(m);
    cin>>b;
    REP(i,n){
        vi a(m);
        cin>>a;
        int sc=c;
        REP(j,m){
            sc+=a[j]*b[j];
        }
        if(sc>0){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 1000000000
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int N,co=0;
	cin>>N;
	vector<int>a(N);
	int ans[100000]={0};
	REP(i,N){
		cin>>a[i];
		if(a[i]>N){
			co++;
			continue;
		}
		ans[a[i]-1]++;
	}
	//REP(i,5)cout<<ans[i]<<endl;
	//cout<<co<<endl;
	REP(i,100000){
		if(ans[i]!=i+1 && ans[i]!=0){
			//cout<<"A"<<endl;
			if(ans[i]>i+1)
				co+=abs(ans[i]-(i+1));
			else
				co+=ans[i];
			
		}
	}
	cout<<co<<endl;
	
	
	return 0;
}

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

int main() {
	int n,q,a[100001]={}; long long k, sum=0;
	cin>>n>>k>>q;
	for(int i=0;i<q;i++){
		int tmp; cin>>tmp;
		a[tmp-1]++;
	}
	
	for(int i=0;i<n;i++) sum+=a[i];
	for(int i=0;i<n;i++){
		long long tmp=sum-a[i];
		if(k>tmp) cout<<"Yes"<<endl;
		if(k<=tmp) cout<<"No"<<endl;
	}
	
	return 0;
}

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

struct Node{
    int key;
    struct Node *right,*left,*parent;
};

struct Node *root,*NIL;

struct Node *treeMin(struct Node *x){
    while(x->left != NIL) x=x->left;
    return x;
}

struct Node *find(struct Node *u,int k){
    while(u!=NIL && k!=u->key){
        if(k<u->key) u=u->left;
        else u=u->right;
    }
    return u;
}

struct Node * treeSuc(struct Node *x){
    if(x->right!=NIL) return treeMin(x->right);
    struct Node *y = x->parent;
    while(y!=NIL && x==y->right){
        x=y;
        y=y->parent;
    }
    return y;
}

void treeDelete(struct Node *z){
    struct Node *y;
    struct Node *x;
    
    if(z->left == NIL || z->right == NIL) y=z;
    else y=treeSuc(z);
    if(y->left != NIL){
        x=y->left;
    }else{
        x=y->right;
    }
    
    if(x!=NIL){
        x->parent=y->parent;
    }
    
    if(y->parent==NIL){
        root=x;
    }else{
        if(y==y->parent->left){
            y->parent->left=x;
        }else{
            y->parent->right=x;
        }
    }
    
    if(y!=z){
        z->key=y->key;
    }
    
    free(y);
}

void insert(int k){
    struct Node *y = NIL;
    struct Node *x = root;
    struct Node *z;
    
    z = (struct Node *)malloc(sizeof(struct Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL){
        root = z;
    }else {
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}


void inorder(struct Node *u){
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(struct Node *u){
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n,i,x;
    char com[10];
    char in[10]="insert";
    char pri[10]="print";
    char dele[10]="delete";
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf(" %s",com);
        if(com[0]=='f'){
            scanf("%d",&x);
        struct Node *t = find(root,x);
        if(t!=NIL)printf("yes\n");
        else printf("no\n");
    }else if(strcmp(com,in)==0){
        scanf("%d",&x);
        insert(x);
    }else if(strcmp(com,pri)==0){
        inorder(root);
        printf("\n");
        preorder(root);
        printf("\n");
    }else if(strcmp(com,dele)==0){
        scanf("%d",&x);
        treeDelete(find(root,x));
    }
    }
    return 0;
}



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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

#define INF 1LL<<60



  int main(){
    ll N;
    cin >> N;
    ll ans = N - 1;
    for(ll i = 1; i * i <= N; i++){
        if(N % i == 0){
          ans = min(ans, (N / i - 1) + (i - 1));
        }
      }
  print(ans);
  
  }


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

int main() {
    long long x,y; cin >> x >> y;
    if(x%y==0) {
        cout << -1 << endl;
        return 0;
    }
    for(long long i = 2; i < 10e7; i ++) {
        if(x*i%y != 0) {
            cout << x*i << endl;
            return 0;
        } 
    }
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1e6+5;
const int maxp = 1005;

int is_pair = 1;
int is_set = 1;

int A[maxn];
int N;

map<int,int> mp;

int isprime[maxp],cnt,factor[maxp],facnum;
int primes[maxp];

void makeprimes(){
     _for(i,2,maxp){
        isprime[i] = 1;
    }
    _for(i,2,maxp){
        if(isprime[i]){
            for(int j = i+i;j < maxp;j += i){
                isprime[j] = 0;
            }
        }
    }
    cnt = 0;
    _for(i,2,maxp){
        if(isprime[i])
            primes[cnt++] = i;
    }
}

void fact(int n)
{
    int max_fac = sqrt(n+1);
	for(int i = 0; i < cnt; i++){
        if(primes[i] > max_fac) break;
        int c = 0;
        _for(j,0,N){
            if(A[j] % primes[i] == 0){
                c++;
                while(A[j] % primes[i] == 0) A[j] /= primes[i];
            }
        }

        if(c >= 2){
            is_pair = 0;
        }
        if(c == N){
            is_set = 0;
        }
        if(!is_pair && !is_set) return;
	}

    _for(i,0,N){
        if(A[i] != 1){
            mp[A[i]]++;
        }
    }
    for(auto a:mp){
        if(a.second >= 2) is_pair = 0;
        if(a.second == N) is_set = 0;
    }

}




int main()
{
    makeprimes();
    //cout << cnt << endl;

    cin >> N;

    _for(i,0,N){
        scanf("%d",&A[i]);
    }

    fact(maxn);

    if(is_pair){
        cout << "pairwise coprime" <<endl;
    }else if(is_set){
        cout << "setwise coprime" <<endl;
    }else{
        cout << "not coprime" <<endl;
    }

    return 0;
}


Measured memory_bytes: 11112
l,r=map(int,input().split())
n=l//2019
m=r//2019
p=l%2019
q=r%2019
a=2018
if p>q:
    print(0)
elif m>n:
    print(0)
else:
    for i in range(p,q):
        for j in range(p+1,q+1):
            c=(i*j)%2019
            if a>c:
                a=c
    print(a)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
typedef long long ll;
using namespace __gnu_pbds;

typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double lld;

lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll i;
    for(i=0;i<b;i++)
        c*=a;
    return c;
}
ll hell=1000000007;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll dp[100005];
ll h[100005];
ll n,i;
ll solve(ll i)
{   if(i==(n-1))
        return 0;
    if(i>=n)
        return 1000000000000000;
    if(dp[i]!=-1)
        return dp[i];
    ll x=min((solve(i+1)+abs(h[i]-h[i+1])),(solve(i+2)+abs(h[i]-h[i+2])));
    dp[i]=x;
    return x;
}

int main()
{

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

    for(i=0;i<n;i++)
        cin>>h[i];
    cout<<solve(0);
    return 0;
}






Measured memory_bytes: 3328
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
int n;
int l[111];
int main(){
  cin>>n;
  rep(i,n)cin>>l[i];
  sort(l,l+n);
  int cnt=0;
  rep(i,n)cnt+=l[i];
  if(l[n-1]<cnt-l[n-1])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
from collections import deque


s = input()

x,y = map(int,input().split())

xlis = []
ylis = []

slis = deque()
for i in s:
    slis.append(i)


while True:
    if len(slis) > 0 and slis[0] == "F":
        x -= 1
        slis.popleft()
    else:
        break

#print(slis,x)

direct = 0
tnum = 0
fnum = 0

while len(slis) > 0:

    nows = slis.popleft()

    if nows == "T":

        if tnum == 0 and fnum != 0:

            if  direct == 0:
                xlis.append(fnum)
            else:
                ylis.append(fnum)

            fnum = 0

        tnum += 1

    if nows == "F":

        direct = (direct + tnum) % 2
        tnum = 0
        fnum += 1

if fnum != 0:

    if direct == 0:
        xlis.append(fnum)
    else:
        ylis.append(fnum)




xdic = {}
ydic = {}


xdic[0] = 1
ydic[0] = 1


for i in xlis:

    nxdic = {}

    for j in xdic:
        nxdic[j + i] = 1
        nxdic[j - i] = 1

    xdic = nxdic.copy()

for i in ylis:

    nydic = {}

    for j in ydic:
        nydic[j + i] = 1
        nydic[j - i] = 1

    ydic = nydic.copy()

if x in xdic and y in ydic:
    print ("Yes")

else:
    print ("No")


Measured memory_bytes: 5256
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;

#define MAX_M 10000
#define MAX_N 500
#define INF 2000000000
int M, N;
int P[MAX_M], C[MAX_N], E[MAX_M];
int dp[MAX_N][MAX_M + 1];

int main(){
	int pre, pt, res, manju;
	for(int i = 0; i < MAX_N; i++){
		for(int j = 0; j <= MAX_M; j++){
			dp[i][j] = INF;
		}
	}
	
	scanf("%d%d", &M, &N);
	for(int i = 0; i < M; i++) scanf("%d", P + i);
	for(int i = 0; i < N; i++) scanf("%d%d", C + i, E + i);
	
	sort(P, P + M, greater<int>());
	
	dp[0][0] = 0;
	for(int i = 1; i <= C[0] && i <= M; i++) dp[0][i] = E[0];
	for(int i = 1; i < N; i++){
		dp[i][0] = 0;
		for(int j = 1; j <= M; j++){
			dp[i][j] = min(dp[i - 1][j], dp[i - 1][max(j - C[i], 0)] + E[i]);
		}
	}
	/*for(int i = 0; i < b[0].C; i++) dp[i] = b[0].E;
	pt = 1;
	for(int i = b[0].C; i < M && pt < N;){
		for(int j = 0; j < b[pt].C && i < M; j++){
			if(b[pt].C > i) pre = 0;
			else pre = dp[i - b[pt].C];
			
			dp[i] = min(pre + b[pt].E, dp[i]);
			i++;
		}
		
		//printf("???????????????\n");
		pt++;
	}*/
	
	res = 0;
	manju = 0;
	for(int i = 1; i <= M; i++){
		manju += P[i - 1];
		res = max(res, manju - dp[N - 1][i]);
		//if(manju - dp[i] > res) res = manju - dp[i];
	}
	
	printf("%d\n", res);
	
	/*for(int i = 0; i < N; i++){
		for(int j = 0; j <= M; j++){
			printf("%d ", dp[i][j]);
		}
		printf("\n");
	}*/
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, k;
	int v[60];
	cin>>n>>k;
	assert(n<=50 || k<=100);
	REP(i, n){
		cin>>v[i];
	}
	int ans=0;
	REP(i, k+1){
		REP(j, k-i+1){
			if(i+j>n){
				continue;
			}
			int x2[i+j];
			REP(j2, i){
				x2[j2]=v[j2];
			}
			int cnt=i-1;
			FORR(j2, n-j, n){
				x2[++cnt]=v[j2];
			}
			sort(x2, x2+i+j);
			int sum=0;
			REP(a, i+j){
				sum+=x2[a];
			}
			REP(a, min(k-i-j, i+j)){
				if(x2[a]>=0){
					break;
				}
				sum-=x2[a];
			}
			CHMAX(ans, sum);
		}
	}
	cout<<ans<<'\n';
	return 0;
}


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


vector<vector<int>> temp(5);
vector<vector<int>> items(5);
int visited[5];

int bfs(int u, int v)
{
	visited[u] = 1;

	queue<int> q;
	q.push(u);

	while (!q.empty())
	{
		int front = q.front();

		q.pop();

		if (front == v)
		{
			return true;
		}

		vector<int> adjs = items[front];

		for (int i = 0; i < (int)adjs.size(); i++)
		{
			if (!visited[adjs[i]])
			{
				visited[adjs[i]] = 1;

				q.push(adjs[i]);
			}
		}
	}

	return false;
}

bool exist(vector<int> items,int item)
{
	for (int i = 0; i < (int)items.size(); i++)
	{
		if (items[i] == item)
			return true;
	}

	return false;
}

int main()
{
	std::ios::sync_with_stdio(false);


	for (int i = 1; i <= 3; i++)
	{
		int u, v;
		cin >> u >> v;

		temp[u].push_back(v);
		temp[v].push_back(u);
	}

	for (int i = 1; i <= 4; i++)
	{
		for (int z = 1; z <= 4; z++)
		{
			if (i!=z &&!exist(temp[i], z)) {
				items[i].push_back(z);
			}
		}
	}

	int t = false;

	for (int i = 1; i <= 4; i++)
	{
		for (int k = 1; k <= 4; k++)
		{
			visited[k] = 0;

		}


		for (int j = i+1; j <= 4; j++)
		{
			int re = bfs(i,j);

			int cnt = 0;

			for (int k = 1; k <= 4; k++)
			{
				cnt+=visited[k];
			}

			if (cnt == 4)
			{
				t = true;
				break;
			}
		}

		if (t)
		{
			break;
		}

	}

	if (t)
	{
		cout << "YES"<<endl;
	}
	else
	{
		cout << "NO" << endl;
	}



	return 0;
}

Measured memory_bytes: 256
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;



int main()
{
  int n;
  cin >> n;
  if(n % 1000 == 0) cout << 0 << endl;
  else cout << 1000 - (n % 1000) << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
	
    int a = 1, b = 1;
    while(!((a == 0)&&(b == 0))) {
        cin >> a >> b;
        for (int i = 1; i <= a; i++) {
            for(int j = 1; j <= b; j++) { 
                if ((i == 1)||(i == a)||(j == 1)||(j == b)) { 
                    cout << '#';
                }    
                else cout << '.';
            }    
            cout << endl;
        }
        if(!(a==0&&b==0)) { 
            cout << endl;
        }    
    }
    return 0;
}


Measured memory_bytes: 3072
#include <stdio.h>

int main(void) {
	long int SC[200][2], buf[200][2], stars[1000][2];
	long int cou = 0, sa[2];
	int n,m,i,c,k;
	
	while(scanf("%d", &m)){
	if(m == 0) break;
	for(i = 0; m > i; i++){
		scanf("%ld%ld", &SC[i][0], &SC[i][1]);
	}
	scanf("%d", &n);
	for(i = 0; n > i; i++){
		scanf("%ld%ld", &stars[i][0], &stars[i][1]);
	}
	for(i = 0; n > i; i++){
		sa[0] = stars[i][0] - SC[0][0];
		sa[1] = stars[i][1] - SC[0][1];
		cou = 0;
		for(c = 0; m > c; c++){
			for(k = 0; n > k; k++){
				if(SC[c][0] + sa[0] == stars[k][0] && SC[c][1] + sa[1] == stars[k][1]){
					cou++;
					break;
				}
			}
		}
		if(cou == m){
			printf("%ld %ld\n", sa[0], sa[1]);
			break;
		} 
		
	}
	}
	return 0;
}

Measured memory_bytes: 1044
while True:
  y,o = 0,0
  x  = int(input())
  if x == 0:
    break
  else:
    for q in range(12):
      m = map(int,raw_input().split())
      m,n = m[0],m[1]
      y += m-n
      if y >= x:
        o += 1

    if y >= x: print 12-o+1
    else:
      print "NA"

Measured memory_bytes: 14000
// AOJ 0142: Nature of Prime Numbers
// 2017.8.16 bal4u@uu
// 2017.11.1 retry

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

#define MAX  10000
#define HALF 5000
int sqr[HALF+5];
int a[HALF+5];
int d[HALF+5];
char f[MAX+5];
char prime[MAX+5];
int tbl[25] = {
  3,  5,  7, 11, 13, 17, 19, 23, 29, 31,
 37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
 79, 83, 89, 97,101 };

int main()
{
	int n;
	int i, j, k, b, m;

	for (i = 0; i < 25; i++) {
		k = tbl[i];
		for (j = k<<1; j < MAX; j += k) prime[j] = 1;
	}

//	for (i = 1; i <= 5000; i++) sqr[i] = i*i;
	for (sqr[1] = 1, i = 2; i <= 5000; i++) sqr[i] = sqr[i-1]+(i<<1)-1;

	while (scanf("%d", &n) && n > 0) {
		k = n >> 1;
		// 4m+3????´???°
		if (!prime[n] && (n & 3) == 3) {
			sprintf(f, "%d", k-1);
			while(k--) puts(f);
			continue;
		}

		// ???????\???°????????????????????????????¨????
		memset(d, 0, sizeof(int)*(k+2));
		memset(f, 0, sizeof(char)*(n+2));
		m = 0;
		for (i = 1; i <= k; i++) {
			b = sqr[i] % n;
			if (!f[b]) f[b] = 1, a[m++] = b;
		}
		for (i = 0; i < m; i++) {
			for (j = 0; j < m; j++) {
				if (b = a[i] - a[j]) {
					if (b < 0) b += n;
					if (b > k) b = n - b;
					d[b]++;
				}
			}
		}
		for (i = 1; i <= k; i++) printf("%d\n", d[i]);
	}
	return 0;
}

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

const int N = 1e3 + 5;

int n, m, a[N][N], f[N][N], visited[N][N], col[N][N];

int dp(int x, int y) {
	if(visited[x][y]) return f[x][y];
	if(x == n && y == m) return f[x][y] = 0;
	visited[x][y] = true; f[x][y] = -1e9;
	int sum = col[n][y + 1] - 2 * col[x][y + 1];
	if(!((x + y) & 1)) sum = -sum;
	if(x + 1 <= n) f[x][y] = max(f[x][y], - dp(x + 1, y));
	if(y + 1 <= m) {
		f[x][y] = max(f[x][y], sum - dp(x, y + 1));
	}
	return f[x][y];
}

int main() {
	cin >> m >> n;
	for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j)
		cin >> a[i][j], col[i][j] = col[i - 1][j] + a[i][j];
	cout << abs(dp(0, 0)) << '\n';
}



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

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


Measured memory_bytes: 25216
# -*- coding: utf-8 -*-

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


MOD = 10 ** 9 + 7


from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def main():
    n, k = input_to_int_map()

    all_n = n + 1
    ret = 0
    all_list_sum = [0]
    pre = 0
    for i in range(0, all_n):
        all_list_sum.append(i + pre)
        pre = i + pre

    for choice_cnt in range(k, all_n + 1):
        ret = (ret + (all_list_sum[n + 1] - all_list_sum[n + 1 - choice_cnt] - all_list_sum[choice_cnt] + 1))

    return ret % MOD


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 19580
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
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; }
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int H, W;
char A[1003][1003];
ll DP[1003][1003];

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

  cin >> H >> W;
  rep(i, H){
    rep(j, W) cin >> A[i][j];
  }

  DP[0][0] = 1;

  rep(h, H){
    rep(w, W){
      if (h < H-1 && A[h+1][w] == '.'){
        DP[h+1][w] += DP[h][w];
        DP[h+1][w] %= MOD;
      }
      if (w < W-1 && A[h][w+1] == '.'){
        DP[h][w+1] += DP[h][w];
        DP[h][w+1] %= MOD;
      }
    }
  }

  cout << DP[H-1][W-1] << endl;
  return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    ll n;
    cin >> n;
    VI a(n, 0), b(n, 1);
    for (i = 0; i < n; i++) {
        string s;
        cin >> s;
        bool f = 0;
        for (j = 0; j < s.size(); j++) {
            if (s[j] == '.')
                f = 1;
            else {
                a[i] *= 10;
                a[i] += s[j] - '0';
                if (f) b[i] *= 10;
            }
        }
    }
    for (i = 0; i < n; i++) {
        ll g = gcd(a[i], b[i]);
        a[i] /= g;
        b[i] /= g;
    }
    VI tw(n, 0);
    VI fi(n, 0);
    for (i = 0; i < n; i++) {
        while (a[i] % 2 == 0) {
            tw[i]++;
            a[i] /= 2;
        }
        while (a[i] % 5 == 0) {
            fi[i]++;
            a[i] /= 5;
        }
        while (b[i] % 2 == 0) {
            tw[i]--;
            b[i] /= 2;
        }
        while (b[i] % 5 == 0) {
            fi[i]--;
            b[i] /= 5;
        }
    }
    for (i = 0; i < n; i++) {
        // cout << tw[i] << " " << fi[i] << endl;
    }
    ll mid = 200;
    VVI w(411, VI(411, 0));
    for (i = 0; i < n; i++) {
        w[tw[i] + mid][fi[i] + mid]++;
    }
    for (i = 399; i >= 0; i--) {
        for (j = 398; j >= 0; j--) {
            w[i][j] += w[i][j + 1];
        }
    }
    for (i = 398; i >= 0; i--) {
        for (j = 399; j >= 0; j--) {
            w[i][j] += w[i + 1][j];
        }
    }
    ll ans = 0;
    for (i = 0; i < n; i++) {
        ans += w[mid - tw[i]][mid - fi[i]];
    }
    for (i = 0; i < n; i++) {
        if (tw[i] >= 0 && fi[i] >= 0) ans--;
    }
    cout << ans / 2 << endl;

    // for (i = 0; i < n; i++) cout << a[i] << " " << b[i] << endl;
}

Measured memory_bytes: 10824
n, a, b = map(int, input().split(' '))
s = input()

passed_count = 0
passed_count_foreigner = 0

for person in s:
    if passed_count < a + b and person == "a":
        print("Yes")
        passed_count += 1
    elif passed_count < a + b and person == "b" and passed_count_foreigner < b:
        print("Yes")
        passed_count += 1
        passed_count_foreigner += 1
    else:
        print("No")

Measured memory_bytes: 9300