akhauriyash/Code-Regression huggingface dataset:
/*
* @author:  codancer
* @createTime:  2020-08-22, 20:02:14
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
#define deb(x) cerr<<#x<<" = "<<(x)<<"\n"
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll Rand(ll B) {
	return (ull)rng() % B;
}
int main(){
	string s;
	cin>>s;
	ll ans=0;
	for(char c:s){
		ans+=c-'0';
	}
	cout<<(ans%9==0?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 3716
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
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;}

int N;
inline void solve(){
  IN(N);
  OUT("ABC"+to_string(N));
}

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


Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << std::endl;
#else
#define DEBUG(message)
#endif

void solve() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ll ans = 0;
  for (size_t i = 1; i < n; i++) {
    ll delta = max(0, a[i - 1] + a[i] - x);
    a[i] -= delta;
    if (a[i] < 0) {
      a[i] = 0;
    }
    ans += delta;
  }
  cout << ans << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
//  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string.h>

using namespace std;

#define _ABS(X) (((X) < 0) ? -(X) : (X))

int main()
{
	int A, B, C;

	scanf("%d %d %d", &A, &B, &C);
	if (B + C <= A) printf("0\n");
	else printf("%d\n", C - (A - B));

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
  ll n,m;
  
  cin>>n>>m;
  
  string s;
  
  cin>>s;
  
  vector<ll>ans;
  
  
  set<ll>st;
  
  for(ll i=0;i<n;i++){
      if(s[i]=='0')
      st.insert(i);
  }
  
  ll i=n;
  
 // ans.pb(n);
  
  while(true){
      auto it=st.lower_bound(i-m);
      
      if(it==st.end()){
          break;
      }
      
      
      ll l=*it;
      
      if(l>=i)
      break;
      
      ans.pb(i-l);
      
      i=*it;
  }
  
  if(i!=0)
  {
      cout<<"-1\n";
      return;
  }
  
  
  reverse(ans.begin(),ans.end());
  
  
  for(ll i=0;i<ans.size();i++)
  cout<<ans[i]<<" ";
  
  cout<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 9012
from collections import Counter

n, x, y = list(map(int, input().split()))
counter = Counter()

for i in range(1, n):
    for j in range(i+1, n+1):
        k = min(j - i, abs(i-x) + abs(j-y) + 1)
        counter[k] += 1

for cnt in range(1, n):
    print(counter[cnt])


Measured memory_bytes: 48604
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int c = sc.nextInt();
		int n = sc.nextInt();
		ArrayList<Point> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int r1 = sc.nextInt();
			int c1 = sc.nextInt();
			int r2 = sc.nextInt();
			int c2 = sc.nextInt();
			if (((r1 == 0 || r1 == r) || (c1 == 0 || c1 == c)) && ((r2 == 0 || r2 == r) || (c2 == 0 || c2 == c))) {
				list.add(new Point(r1, c1, i));
				list.add(new Point(r2, c2, i));
			}
		}
		Collections.sort(list, new Comparator<Point>() {
		public int compare(Point p1, Point p2) {
			if (p1.row == 0 || p1.col == c) {
				if (p2.row == 0 || p2.col == c) {
					return p1.row + p1.col - p2.row - p2.col;
				} else {
					return -1;
				}
			} else {
				if (p2.row == 0 || p2.col == c) {
					return 1;
				} else {
					return p2.row + p2.col - p1.row - p1.col;
				}
			}
		}
		});
		ArrayDeque<Point> deq = new ArrayDeque<>();
		for (Point p : list) {
			if (deq.size() > 0 && deq.getLast().idx == p.idx) {
				deq.pollLast();
			} else {
				deq.addLast(p);
			}
		}
		if (deq.size() == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
	
	static class Point {
		int row;
		int col;
		int idx;
		public Point(int row, int col, int idx) {
			this.row = row;
			this.col = col;
			this.idx = idx;
		}
		public String toString() {
			return "row:" + row + " col:" + col + " idx:" + idx;
		}
	}
}


Measured memory_bytes: 98744
#include <stdio.h>
#include <string.h>
int main(void){

	char str[100], c;
	int i, abc[256];

	scanf("%s", &str);
	for(i='a'; i<='z'; i++){
		abc[i]=0;
	}

	for(i=0; i<strlen(str); i++){
		c = str[i];
		abc[c]++;
	}

	for(i='a'; i<='z'; i++){
		if(abc[i]%2!=0){
			printf("No\n");
			break;
		}
		if(i=='z') printf("Yes\n");
	}

	return 0;
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

const double EPS = 1e-9;

class Point{
    public: 
    long double x,y;
    
    Point(long double x = 0.0, long double y = 0.0): x(x), y(y) {}
    
    Point operator + (Point p) {
        return Point(x+p.x, y+p.y);
    }
    Point operator - (Point p) {
        return Point(x-p.x, y-p.y);
    }
    Point operator * (long double a) {
        return Point(x*a, y*a);
    }
    Point operator / (long double a) {
        return Point(x/a, y/a);
    }
    bool operator < (const Point &p) const {
        return (x != p.x ? x < p.x : y < p.y);
    }
    bool operator == (const Point &p) const {
        return fabsl(x - p.x) < EPS && fabsl(y - p.y) < EPS;
    }
    
    long double abs() {
        return sqrt(norm());
    }
    
    long double norm() {
        return x*x + y*y;
    }
    
    long double dot(Point p) {
        return x*p.x + y*p.y;
    }
    
    long double cross(Point p) {
        return x*p.y - y*p.x;
    }
};

class Segment{
    public: 
    Point p,q;
    long double grad;
    
    Segment(Point p, Point q) {
        this->p = p;
        this->q = q;
        this->grad = (q.y-p.y)/(q.x-p.x);
    }
    
};

Point project(Segment s, Point p){
    Point base = s.q - s.p;
    long double t = base.dot(p-s.p) / base.abs();
    return s.p + base * (t / base.abs());
}

Point reflect(Segment s, Point p){
    return p + (project(s, p) - p) * 2.0;
}
int main(){
    int n;
    long double x,y;
    Point p[2];
    rep(2){
        scanf("%Lf %Lf", &x, &y);
        p[i] = Point(x, y);
    }
    Segment s = Segment(p[0], p[1]);

    cin >> n;

    rep(n){
        scanf("%Lf %Lf", &x, &y);
        Point q = Point(x, y);
        Point ans = reflect(s, q);
        printf("%.10Lf %.10Lf\n", ans.x, ans.y);
    }

}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#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 chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	string s, t;
	cin >> s >> t;

	int n = s.size();
	bool ok = false;
	while (n--)
	{
		if (s == t) 
		{
			ok = true;
			break;	
		}
		char tail = s.back();
		s.pop_back();
		s = tail + s;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

	solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N,Y;
  cin >> N;
  for(int i=0; i<N; i++){
    string x;
    cin >> x;
    if(x=="Y"){
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}

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

using namespace std;

typedef pair<char, int> Card;

vector<Card> Bubble(vector<Card> A) {
  for (int i = 0; i < A.size(); i++) {
    for (int j = A.size()-1; j > i; j--) {
      if (A[j].second < A[j-1].second) swap(A[j], A[j-1]);
    }
  }
  return A;
}

vector<Card> Selection(vector<Card> A) {
  for (int i = 0; i < A.size(); i++) {
    int mini = i;
    for (int j = i; j < A.size(); j++) {
      if (A[j].second < A[mini].second) mini = j;
    }
    swap(A[i], A[mini]);
  }
  return A;
}

void print(vector<Card> org, vector<Card> A) {
  for (int i = 0; i < A.size(); i++) {
    cout << A[i].first << A[i].second;
    if (i != A.size()-1) cout << ' ';
    else cout << endl;
  }

  multimap<int, char> o, a;
  for (int i = 0; i < org.size(); i++) {
    o.insert(pair<int, char>(org[i].second, org[i].first));
    a.insert(pair<int, char>(A[i].second, A[i].first));
  }

  bool flg = true;
  for (int i = 1; i <= 9; i++) {
    int count = o.count(i);
    if (count > 1) {
      multimap<int, char>::iterator o_itr = o.find(i), a_itr = a.find(i);
      for (int j = 0; j < count; j++) {
	if (o_itr->second != a_itr->second) {
	  flg = false;
	  break;
	}
      }
    }
    if (!flg) break;
  }
  if (!flg) cout << "Not stable" << endl;
  else cout << "Stable" << endl;
}

int main(int argc, char* argv[]) {
  int N; cin >> N;
  vector<Card> A(N);

  int diff = 0-'0';
  for (int i = 0; i < N; i++) {
    string s; cin >> s;
    A[i] = Card(s[0], s[1]+diff);
  }

  print (A, Bubble(A));
  print (A, Selection(A));
  
  return 0;
}

Measured memory_bytes: 1208
FLAG = False

N = int(input())
S = list(input())

if N % 2 == 1 :
    FLAG = True
    print("No")

half = int(N / 2)

if FLAG == False :
    for s in S :
        if half < N :
            half = half + 1

        if s is S[half - 1] :
            pass
        else :
            print("No")
            break

        if N == half:
            print("Yes")
            break

Measured memory_bytes: 3060
n,m = map(int,input().split())
lis = list(map(str,input().split()))
while 1:
    for i in range(len(str(n))):
        if str(n)[i] in lis:
            break
        if i == len(str(n))-1:
            print(n)
            exit()
    n += 1

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

int main(){
  int n, r, t;
  cin >> n >> r >> t;
  int p[110];
  int now[110] = {};
  int old[110] = {};
  int drink[1010] = {};
  int ans = 0;
  for(int i = 0;i < n;i++) cin >> p[i];

  for(int i = 0;i < t;i++){
    for(int j = 0;j < n;j++){
      old[j] = now[j];
      now[j] = (now[j] + p[j]) % r;
      if(drink[now[j]] == 0){
        ans++;
      }else{
        drink[now[j]]--;
      }
    }
    if(i > 0){
      for(int j = 0;j < n;j++) drink[now[j]]++;
    }
  }

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





Measured memory_bytes: 3116
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9+7;
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};

void solve() {
	int h,a;
	cin >> h>>a;
	cout << ceil((1.0*h)/a) <<endl;

}

signed main() {
	boost;
	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0; }
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0; }

using namespace std;

int main(void){
	int x, y, s;
	while(cin>>x>>y>>s, x, y, s) {
		int res = 0;
		rep(i,1,s-1) {
			rep(j,1,s-1) {
				if((int)(i*(100+x)/100)+(int)(j*(100+x)/100) == s) {
					chmax(res, (int)(i*(100+y)/100)+(int)(j*(100+y)/100));
				}
			}
		}
		cout << res << endl;
	}
        
	return 0;
}

Measured memory_bytes: 2988
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
const int INF = 100000000;

int main() {
  vector<int> dp(60000, INF);
  dp[0] = 0;
  int n, m;
  cin >> n >> m;
  vector<int> c(m);
  rep(i, m) cin >> c[i];
  rep(i, n+1){
    rep(j, m){
      if(i - c[j] >= 0){ 
        dp[i] = min(dp[i], dp[i- c[j]] + 1);
      }
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
#define MAX 100000
using namespace std;


int main()
{
  fastio
  int t;
  /* cin >> t; */
  /* while(t--) */
  /* { */
  /* } */
  double a;
  cin >> a;
  cout << 2*PI*a;



    


  return 0;
}




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

int main(){
	int N;
	cin >> N;
	int L[N];
	for(int i = 0; i< N; i++)
		cin >> L[i];
	int maxl = 0, sum = 0;
	for(int i = 0; i < N; i++){
		maxl = max(maxl,L[i]);
		sum += L[i];
	}
	if(maxl < sum-maxl)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int H, W;
  cin >> H >> W;
  string S[H+2];
  
  for (int i=1; i<H+1; i++){
    cin >> S[i];
    S[i] = '.' + S[i] + '.';
  }

  S[0] = S[1];
  for (int i = 0; i<W+2; i++)
    S[0].at(i) = '.';
  S[H+1] = S[0];

  
  for (int i=1; i<H+1; i++){	//i行目の処理
    
    for (int j=1; j<W+1; j++){	//j列目の処理
     
      if (S[i].at(j) == '.'){	//空きなのでカウント

        int count = 0;

        for (int l = i-1; l < i+2; l++){
          for (int k = -1; k < 2; k++){
            if (S[l].at(j+k) == '#')
              count++;
          }    
        }        
        cout << count;
        
      }else
        cout << '#';	//爆弾
      
    }
    
    cout << endl;
    
  }
  
}

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

int main(){
  int n;	cin >> n;
  
  int c=0;
  int m=0;
  rep(i,n){
    int first,second;	cin >> first >> second;
    if(first==second)	c++;
    else{
      m=max(c,m);
      c=0;
    }
  }
  m=max(c,m);
  
  if(m>=3)	cout << "Yes";
  else cout << "No";
}


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


int main() {

	int N;
	cin >> N;

	vector<string> s(N);
	for (int i = 0; i < N; i++)
	{
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}

	sort(s.begin(), s.end());
	
	//for (int i = 0; i < N; i++)
	//{
	//	cout << s[i] << endl;
	//}


	// A A A A A B C C C D D E E E F F F
	// のように同じ文字列が固まったものをチェックしていく
	long long ans = 0;
	int count = 0;
	for (int i = 1; i < N; i++)
	{
		if (s[i] == s[i-1]) {
			count++;
			ans += count;
		}
		else {
			count = 0;
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7296
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.awt.Point;

public class Main {
    // static int INF = (1 << 30) - 1;
    // static long L_INF = (1L << 62) - 1;
    // static long MOD = (long) 1e9 + 7;

    static class Solver {
        int N;
        long[] A;
        HashMap<Long, Long> mp;
        long sum;

        // write your code
        void solve(InputReader in, PrintWriter out) {
            N = in.nextInt();
            A = new long[N];
            mp = new HashMap<>();
            for (int i = 0; i < N; i++) {
                A[i] = in.nextLong();
                sum += A[i];
                Long l = 0l;
                mp.putIfAbsent(A[i], l);
                mp.put(A[i], mp.get(A[i]) + 1);
            }
            int Q = in.nextInt();
            for (int i = 0; i < Q; i++) {
                long b = in.nextLong();
                long c = in.nextLong();
                Long v = mp.get(b);
                if (v != null) {
                    Long l = 0l;
                    long bNum = mp.get(b);
                    sum -= (bNum * b);
                    // long cNum = mp.get(c);
                    mp.putIfAbsent(c, l);
                    mp.put(c, mp.get(c) + v);
                    mp.put(b, l);
                    sum += (bNum * c);
                }
                out.println(sum);
            }
        }

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

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 61984
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m;
  cin>>n>>m;
  int a[100];
  vector<int> odd;
  for(int i=0; i<m; i++){
    cin>>a[i];
    if(a[i]%2) odd.push_back(a[i]);
  }
  if(odd.size()>=3){
    cout<<"Impossible"<<endl;
    return 0;
  }
    
  vector<int> ap, b;
  if(odd.size()==2){
    ap.push_back(odd[0]);
    for(int i=0; i<m; i++){
      if(a[i]%2==0) ap.push_back(a[i]);
    }
    ap.push_back(odd[1]);
	if(ap[0]==1 && ap[m-1]==1){
      b.push_back(2);
      for(int i=1; i<m-1; i++){
        b.push_back(ap[i]);
      }
    }else if(ap[0]==1){
      b.push_back(2);
      for(int i=1; i<m-1; i++){
        b.push_back(ap[i]);
      }
      b.push_back(ap[m-1]-1);
    }else{
      b.push_back(ap[0]-1);
      for(int i=1; i<m-1; i++){
        b.push_back(ap[i]);
      }
      b.push_back(ap[m-1]+1);
    }
  }else if(odd.size()==1){
    if(m==1){
      ap.push_back(a[0]);
      for(int i=0; i<n/2; i++){
        b.push_back(2);
      }
      b.push_back(1);
    }else{
    ap.push_back(odd[0]);
    for(int i=0; i<m; i++){
      if(a[i]%2==0) ap.push_back(a[i]);
    }
    b.push_back(ap[0]+1);
    for(int i=1; i<m-1; i++) b.push_back(ap[i]);
    b.push_back(ap[m-1]-1);
    }
  }else{
    if(m==1){
      cout<<a[0]<<endl;
      cout<<n/2+1<<endl;
      if(n%4==2){
        cout<<1<<" ";
        for(int i=0; i<n/2/2; i++){
          cout<<2<<" ";
        }
        cout<<1<<" ";
        for(int i=0; i<n/2/2; i++){
          cout<<2<<" ";
        }
        cout<<endl;
      }else{
        cout<<1<<" ";
        for(int i=0; i<n/2/2-1; i++){
          cout<<2<<" ";
        }
        cout<<1<<" ";
        for(int i=0; i<n/2/2; i++){
          cout<<2<<" ";
        }
        cout<<endl;
      }
      return 0;
    }
    for(int i=0; i<m; i++){
      ap.push_back(a[i]);
    }
    b.push_back(ap[0]+1);
    for(int i=1; i<m-1; i++) b.push_back(ap[i]);
    b.push_back(ap[m-1]-1);
  }
  for(auto x:ap) cout<<x<<" ";
  cout<<endl;
  cout<<b.size()<<endl;
  for(auto x:b) cout<<x<<" ";
  cout<<endl;
	return 0;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};
#[fastout]
fn main() {
    input!(n: usize,m:usize,mut x:[isize;m]);

    x.sort();
    let mut x_m = Vec::<isize>::new();
    for i in 1..x.len() {
        x_m.push(x[i] - x[i - 1]);
    }

    x_m.sort();
    let ans = (0..if x_m.len() < (n - 1) {
        0
    } else {
        x_m.len() - (n - 1)
    })
        .map(|x| x_m[x])
        .sum::<isize>();

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


Measured memory_bytes: 4532
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    int n;
    int hh,mm,ss,st,en;
    int time[86401];
    char ch;
    while(1){
        cin >> n;
        if(n == 0)  break;
        for(int j = 0; j < 86400; j++){
            time[j] = 0;
        }
        for(int i = 0; i < n; i++){
            cin >> hh >> ch >> mm >> ch >> ss;
            st = hh * 3600 + mm * 60 + ss;
            cin >> hh >> ch >> mm >> ch >> ss;
            en = hh * 3600 + mm * 60 + ss;
            for(int j = st; j < en; j++){
                time[j]++;
            }
        }
        
        int maxt = 0;
        for(int i = 0; i < 86400; i++){
            if(maxt < time[i])  maxt = time[i];
        }
        
        cout << maxt << endl;
        
    }
    
    return 0;
}



Measured memory_bytes: 3408
N = int(input())
L = [[int(l) for l in input().split()] for _ in range(N)]

def dist(x, y, x0, y0):
    return ((x-x0)**2 + (y-y0)**2)**0.5

def f(x, y):
    res = 0
    for i in range(N):
        res = max(res, dist(L[i][0], L[i][1], x, y))
    return res

lx = -10**4
rx = 10**4
for _ in range(100):
    cx1 = (lx*2 + rx) / 3
    ly = -10**4
    ry = 10**4
    for _ in range(100):
        cy1 = (ly*2 + ry) / 3
        cy2 = (ly + ry*2) / 3
        if f(cx1, cy1) < f(cx1, cy2):
            ry = cy2
        else:
            ly = cy1
    y = (ly + ry) / 2
    
    cx2 = (lx + rx*2) / 3
    ly = -10**4
    ry = 10**4
    for _ in range(100):
        cy1 = (ly*2 + ry) / 3
        cy2 = (ly + ry*2) / 3
        if f(cx2, cy1) < f(cx2, cy2):
            ry = cy2
        else:
            ly = cy1

    if f(cx1, y) < f(cx2, ly):
        rx = cx2
        ans = f(cx1, y)
    else:
        lx = cx1
        ans = f(cx2, ly)

print(ans)

Measured memory_bytes: 49384
def shift_only(array):
    tmp = []
    counter = 0
    while True:
        flag = True
        # 全て偶数かを確認
        for num in array:
            if num%2 != 0:
                flag = False
        if flag == False:
            break
        array = [i/2 for i in array]
        counter +=1
    print(counter)
    
n = int(input())
a = list(map(int, input().split()))
shift_only(a)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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







class weighted_unionfind {
private:
    vector<int> par;
    vector<int> rank;
    vector<ll> diff_weight;
public:
    weighted_unionfind(int n) : rank(n), diff_weight(n) {
        for (int i = 0; i < n; i++) {
            par.push_back(i);
        }
    }
    
    int find(int x){
        if (par[x] == x) {
            return x;
        }
        else {
            int t = find(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = t;
        }
    }
    
    void unite(int x, int y, ll w){
        w += weight(x);
        w -= weight(y);
        x = find(x);
        y = find(y);
        if (x == y)return;
        
        if (rank[x] < rank[y]) {
            swap(x, y);
            w = -w;
        }
        if(rank[x] == rank[y]){
            rank[x]++;
        }
        
        par[y] = x;
        diff_weight[y] = w;
    }
    
    bool same(int x, int y){
        return find(x) == find(y);
    }
    
    ll weight(int x){
        find(x);
        return diff_weight[x];
    }
    
    ll diff(int x, int y){
        return weight(y) - weight(x);
    }
};




int main(){
    ll n, m;
    cin >> n >> m;
    
    weighted_unionfind uni(n);
    
    REP(i, m){
        ll l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        if(uni.same(l, r)){
            ll diff = uni.diff(l, r);
            if(diff != d){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            uni.unite(l, r, d);
        }
    }
    
    cout << "Yes" << endl;
}

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

	int r;
	cin >> r;
	cout << r * r << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	int  a, b;
	cin >> a >> b;
	if ((a + b) >= 10) cout << "error";
	else cout << (a + b);
	return 0;
}

Measured memory_bytes: 256
adic_i::Int->Int->Int
adic_i i n = if n < i then n else (mod n i)+(adic_i  i (div n i))

solver::Int->Int
solver n = minimum [(adic_i 6 (n-i))+(adic_i 9 i)|i<-[0..n]]

main::IO()
main=do
  nc<-getLine
  let n=read nc
  print (solver n)

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
struct Node;
vector<Node> V;
struct Node {
  bool col = false;
  vector<int> nbr;
  bool vst = false;
  int ans = -1;
  void dfs(bool c) {
    vst = true;
    col = c;
    for(int x : nbr) {
      if(!V[x].vst) {
        V[x].dfs(!c);
      }
    }
  };
};
int main()
{
    int N;
    cin >> N;
    REP(i, N) V.emplace_back();
    REP(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        V[a].nbr.push_back(b);
        V[b].nbr.push_back(a);
    }
    V[0].dfs(false);
    int x = N / 3;
    int y = N % 3;
    int n1 = x;
    int n2 = x;
    int n3 = x;
    if(y >= 1) n1++;
    if(y >= 2) n2++;
    int nfalse = 0;
    int ntrue = 0;
    REP(i, N) {
        if(V[i].col) {
            ntrue++;
        } else {
            nfalse++;
        }
    }
    if(nfalse > ntrue) {
        swap(nfalse, ntrue);
        REP(i, N) V[i].col = !V[i].col;
    }
    int idx1 = 1;
    int idx2 = 2;
    int idx3 = 3;
    if(nfalse <= n3) {
        REP(i, N) {
            if(!V[i].col) {
                V[i].ans = idx3;
                idx3 += 3;
            } else if(idx1 <= N) {
                V[i].ans = idx1;
                idx1 += 3;
            } else if(idx2 <= N) {
                V[i].ans = idx2;
                idx2 += 3;
            } else {
                V[i].ans = idx3;
                idx3 += 3;
            }
        }
    } else {
        int to13 = nfalse - n1;
        int to23 = ntrue - n2;
        REP(i, N) {
            if(!V[i].col) {
                if(to13 > 0) {
                    V[i].ans = idx3;
                    idx3 += 3;
                    to13--;
                } else {
                    V[i].ans = idx1;
                    idx1 += 3;
                }
            } else {
                if(to23 > 0) {
                    V[i].ans = idx3;
                    idx3 += 3;
                    to23--;
                } else {
                    V[i].ans = idx2;
                    idx2 += 3;
                }
            }
        }
    }
    REP(i, N) cout << V[i].ans << (i!=N-1 ? " " : "");
    cout << endl;

}

Measured memory_bytes: 18280
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""
バケットで管理したかったけど数字が多いのでソートして同じ数を固めることに
"""
#solution:
#潜 影 蛇 手 ! !
N=int(input())
a=[]
for i in range(N):
    a.append(int(input()))
a.sort()
bac=1
ans=0
for j in range(N-1):
    if a[j+1]!=a[j]:
        ans+=bac%2
        bac=1
    else:
        bac+=1
ans+=bac%2
print(ans)

Measured memory_bytes: 50392
/*  CREATED BY
    STREAM_CIPHER
    7-aug-2020
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define debug1(a) cout<<#a<<"="<<(a)<<"\n"
#define debug2(a,b) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<"\n"
#define debug3(a,b,c) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<","<<#c<<"="<<(c)<<"\n"
#define fix_precision(n) cout << fixed << setprecision(n)
#define all(a) a.begin(),a.end()
const double pi=acos(-1.0);
int inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int mx=5*1000000;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    #endif
        int n,w;cin>>n>>w;
        vector<pair<int,int>>a(n+1);
        int sum=0;
        for(int i=0;i<n;i++)
            cin>>a[i].first>>a[i].second,sum+=a[i].second;
        int dp[n+9][sum+9];
        memset(dp,inf,sizeof dp);
        dp[0][a[0].second]=a[0].first;
        // cout<<dp[0][a[0].second]<<endl;
        for(int i=1;i<n;i++)
        {
            for(int j=1;j<=sum;j++)
            {
                if(j+a[i].second<=sum&&dp[i-1][j]!=inf)
                    dp[i][j+a[i].second]=min(dp[i-1][j+a[i].second],min(dp[i-1][j]+a[i].first,dp[i][j+a[i].second]));
                dp[i][j]=min(dp[i-1][j],dp[i][j]);
            }
            dp[i][a[i].second]=min(dp[i-1][a[i].second],min(dp[i][a[i].second],a[i].first));
            // cout<<dp[1][a[0].second]<<endl;
            // dp[i][a[i].second]=dp[i-1][a[i].second];
        }
        // for(int i=0;i<3;i++)
        // {
        //     for(int j=1;j<=140;j++)
        //         if(dp[i][j]!=inf) cout<<dp[i][j]<<" ";
        //     cout<<endl;
        // }
        int ans=0;
        for(int i=0;i<n;i++)
            for(int j=1;j<=sum;j++)
                if(dp[i][j]<=w)
                    ans=max(ans,j);
        cout<<ans<<endl;
}

Measured memory_bytes: 88664
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
//typedef vector<vector<P> > Graph;
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; }
const ll INF = 1e18;


//抽象化したセグメント木
//SegmentTree<T>(n,fx,ex):モノイド(集合T,二項演算fx, 単位元ex)についてサイズnで構築
template<typename T>
struct  SegmentTree{
    using FX = function<T(T,T)>;
    int n;
    FX fx;
    const T ex;
    vector<T>node;

    //初期化(datは単位元exで初期化する)
    SegmentTree(int n_, FX fx_, T ex_) : n(),fx(fx_),ex(ex_),node(n_*4,ex_){
        int x = 1;
        while(n_ > x)x*=2;
        n = x;
    }
    
    void set(int i, T x){//最下段の要素の構築
        node[i+n-1]=x;
    }

    void build(){
        for(int i=n-2;i>=0;i--){
            node[i]=fx(node[2*i+1],node[2*i+2]);
        }
    }

    //i番目の要素の更新,計算量O(log(n))
    void update(int i, T x){
        i += n-1;
        node[i]=x;
        while(i>0){
            i=(i-1)/2;
            node[i]=fx(node[i*2+1],node[i*2+2]);
        }
    }

    //query(a,b)は[a,b)全てにfxを作用させた値の取得,計算量はO(log(n))
    T query(int a,int b){
        return query_sub(a,b,0,0,n);
    }

    T query_sub(int a,int b,int k,int l,int r){
        if(r<=a || b<=l){//区間が全くかぶらない時は単位元を返す
            return ex;
        }
        if(a<=l && r <= b){//区間を完全に覆っている時
            return node[k];
        }
        T vl = query_sub(a,b,k*2+1,l,(l+r)/2);
        T vr = query_sub(a,b,k*2+2,(l+r)/2,r);
        return fx(vl,vr);
    }
};


//入力
ll n;

int main(){
    cin >> n;
    auto fx = [](int x1,int x2) -> int{
        return __gcd(x1,x2);
    };
    int ex = 0;
    SegmentTree<int> seg(n,fx,ex);
    rep(i,n){
        int a;
        cin >> a;
        seg.set(i,a);
    }
    seg.build();
    int ans = 0;
    rep(i,n){
        int now1 = seg.query(0,i);
        int now2 = seg.query(i+1,n);
        int now = __gcd(now1,now2);
        chmax(ans,now);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int y = stoi(s.substr(0, 4));
    int m = stoi(s.substr(5, 2));
    int d = stoi(s.substr(8, 2));

    if (y <= 2019 && m <= 4 && d <= 30) cout << "Heisei" << endl;
    else cout << "TBD" << endl;

    return 0;
}

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

typedef long long 		ll;
typedef vector<ll> 		vll;
typedef pair<ll,ll> 	pll;
typedef vector<pll> 	vpll;
typedef vector<int> 	vi;
typedef pair<int,int> 	pii;
typedef vector<pii> 	vpii;

#define fi				first
#define se 				second
#define pb 				push_back
#define mp 				make_pair
#define all(v)			v.begin(),v.end()
#define sz(v)			s.size()
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define per(i,a,b) 		for(int i=a;i>=b;i--)
#define fill(a,v)		memset(a,v,sizeof(a))
#define tc				int T;cin>>T;while(T--)
#define nl				printf("\n")
#define aya				cerr<<"yaha aya"<<"\n"
#define debug(x,y)		printf("%d %d\n",x,y)
#define fast_io			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define grt				greater<int>()

const int mod = 1e9+7;
const int mod2= 1e9+9;

inline int pow_(ll a, int n, int p=mod){
	int r=1;while(n){if(n&1)r=r*a%p;n>>=1;a=a*a%p;}return r;
}

int main(void)
{
	double R;
	cin >> R;
	double ans = 2 * M_PI * R;
	cout << fixed << setprecision(12) << ans << "\n";
}


Measured memory_bytes: 3800
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, W, H, N, x[101], y[101], a[101];
	scanf("%d %d %d", &W, &H, &N);
	for (i = 1; i <= N; i++) scanf("%d %d %d", &(x[i]), &(y[i]), &(a[i]));
	
	int left = 0, right = W, bottom = 0, top = H;
	for (i = 1; i <= N; i++) {
		switch (a[i]) {
		case 1:
			if (x[i] > left) left = x[i];
			break;
		case 2:
			if (x[i] < right) right = x[i];
			break;
		case 3:
			if (y[i] > bottom) bottom = y[i];
			break;
		case 4:
			if (y[i] < top) top = y[i];
		}
	}
	
	int area = (right - left > 0 && top - bottom > 0)? (right - left) * (top - bottom): 0;
	printf("%d\n", area);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a<b && b<c){
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

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;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll d;
    cin>>d;
    vector<ll> c(26);
    rep(i,26){
        cin>>c[i];
    }
    vector<vector<ll>> s(d,vector<ll>(26));
    rep(i,d){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    vector<ll> last(d,0);
    rep(i,d){
        ll cnt=-inf;
        ll ans;
        rep(t,26){
            ll now=0;
            now+=s[i][t];
            ll tmp=last[t];
            last[t]=i+1;
            rep(j,26){
                now-=c[j]*(i+1-last[j]);
            }
            last[t]=tmp;
            if(chmax(cnt,now)){
                ans=t+1;
            }
        }
        last[ans-1]=i+1;
        cout<<ans<<endl;
    }   
}

Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <set>
using namespace std;
using ll = long long;
ll BASE_NUM = 1000000007;

int main()
{
  // 整数の入力
  ll N, M;
  cin >> N;
  map<ll,ll> plus_counts;
  map<ll,ll> minus_counts;
  vector<pair<ll,ll>> A;
  for(int i = 1;i<= N;i++){
    ll a;
    cin >> a;
    A.push_back({a,i});
    // cout << a - i << endl;
    // cout << a + i << endl;
    plus_counts[a - i]++;
    minus_counts[a + i]++;
  }
  // cout << " ==" << endl;
  ll ans = 0;
  for(auto a:A){
    // cout << a.first << " " << a.second << endl;
    ans += plus_counts[- a.first -  a.second];
    ans += minus_counts[- a.first + a.second];
  }
  cout << ans /2 << endl;

  return 0;
}


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

//1  11  1  11
//2  12  2  12
//3  13  3  0
int main() {
    int n;
    cin >> n;
    for(int i = 1; i <= 9;i++){
        if(n % i ==0 && n / i <= 9 && n <82){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b,c,w;
	cin>>a>>b>>c;
	a*=100;
	b*=10;
	w=a+b+c;
	if(w%4==0){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            while(true){
                int n = sc.nextInt();
                int r = sc.nextInt();

                if(n==0){
                    break;
                }
                int[] card = new int[n];
                for(int i=0;i<n;i++){
                    card[i] = n-i;
                }

                for(int i=0;i<r;i++){
                    int p = sc.nextInt();
                    int c = sc.nextInt();

                    int[] shuffleC = new int[c];
                    int[] shuffleP = new int[p];

                    for(int j=0;j<p-1;j++){
                        shuffleP[j] = card[j];
                    }
                    for(int j=0;j<c;j++){
                        shuffleC[j] = card[p-1+j];
                    }

                    for(int j=0;j<c;j++){
                        card[j] = shuffleC[j];
                    }
                    for(int j=0;j<p-1;j++){
                        card[j+c] = shuffleP[j];
                    }

                    shuffleC = null;
                    shuffleP = null;

                }
                
                System.out.println(card[0]);
                
                card =null;
            }
        }  
    }
}


Measured memory_bytes: 37276
//AnkitCode99 here....
#include<bits/stdc++.h>
#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)
using namespace std;

const ll sz=100005;
const ll szz=1000006;

int main()
{
	fast;
    
//     #ifndef ONLINE_JUDGE
// 	freopen("input.txt","r",stdin);
// 	freopen("op.txt","w",stdout);
// 	#endif

    ll k,n;
    cin>>k>>n;

    ll ar[n];
    rep(i,0,n)
    {
    	cin>>ar[i];
    }
//    ll sum=0;
//    rep(i,0,n-1)
//    {
//    	sum+=(ar[i+1]-ar[i]);
//    }
    // cout<<sum<<endl;
    ll dif[n];
    dif[0]=(k-ar[n-1])+ar[0];
    // cout<<dif[0]<<" ";
    ll sum=dif[0];
    rep(i,1,n)
    {
    	dif[i]=ar[i]-ar[i-1];
    	sum+=dif[i];
    // 	cout<<dif[i]<<" ";
    }
    //cout<<endl;
    // ll j;
//    rep(i,1,n)
//    {
//    	ll j=(i+1)%n;
//    	ll temp=0;
//    	while(j!=i)
//    	{
//    		temp+=dif[j];
//    		j=j+1;
//    		j%=n;
//    	}
//    	//cout<<temp<<" ";
//    	sum=min(sum,temp);
//    }

	ll ans=inf;
	rep(i,0,n)
	{
		if(sum-dif[i]<ans)
		{
			ans=sum-dif[i];
		}
	}
    cout<<ans;
}
//Goodbye...


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string>
#include <bits/stdc++.h>

using namespace std;

int num(int x){
  int ret = 0;
  while (x > 0){
    ret += x%10;
    x /= 10;
  }
  return ret;
}
int main(){
  int N, i, j, k;
  cin >> N;
  i = num(N);
  if (N%i == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256