akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		
		int sum = 0;
		for (int i = 0; i < n.length(); i++) {
			int num = Integer.valueOf(n.substring(i, i + 1));
			sum += num;
		}
		
		String ans = sum % 9 == 0 ? "Yes" : "No";
		System.out.println(ans);
		
		sc.close();
	}

}




Measured memory_bytes: 40656
#include<iostream>
using namespace std;
 
int main(){
  int a[3][3];
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      cin>>a[i][j];
  int n,b[10];
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>b[i];
  
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      for(int k=0;k<n;k++)
        if(a[i][j]==b[k])a[i][j]=1;
  
  if(a[0][0]==1&&a[0][1]==1&&a[0][2]==1)cout<<"Yes"<<endl;
  else if(a[1][0]==1&&a[1][1]==1&&a[1][2]==1)cout<<"Yes"<<endl;
  else if(a[2][0]==1&&a[2][1]==1&&a[2][2]==1)cout<<"Yes"<<endl;
  else if(a[0][0]==1&&a[1][1]==1&&a[2][2]==1)cout<<"Yes"<<endl;
  else if(a[0][2]==1&&a[1][1]==1&&a[2][0]==1)cout<<"Yes"<<endl;
  else if(a[0][0]==1&&a[1][0]==1&&a[2][0]==1)cout<<"Yes"<<endl;
  else if(a[0][0]==1&&a[1][1]==1&&a[2][1]==1)cout<<"Yes"<<endl;
  else if(a[0][2]==1&&a[1][2]==1&&a[2][2]==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
typedef pair<int, int> P;

signed main(){
  lint N; cin >> N;
  vector<P> arm(N);
  for(lint i = 0; i < N; i++){
    lint x, l; cin >> x >> l;
    arm[i] = P(x + l, x - l);
  }
  sort(arm.begin(), arm.end());
  lint ans = 0, start = -1e9;
  for(lint i = 0; i < N; i++){
    if(start <= arm[i].second){
      ans++;
      start = arm[i].first;
    }
  }
  cout << ans << endl;
}

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

int n;
int a[100];

void printa(){
	for(int i=0; i<n; i++){
		cout << a[i];
		if(i!=n-1) cout << " ";
	}
	cout << endl;
}

void swap(int i, int j){
	int tmp = a[i];
	a[i] = a[j];
	a[j] = tmp;
}

void movek(int k){
	for(int i=k; i>=1; i--){
		if(a[i]<a[i-1]) swap(i, i-1);
	}
}

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

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	string s;
	int k;
	cin >> s >> k;
	int ans = 0;
	int a, b, sum = 0;
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[i] == s[j]) j++;
		ans += (j - i) / 2 * k;
		if (i == 0) a = j - i;
		if (j == s.size()) b = j - i;
		i = j;
		sum++;
	}
	if (sum == 1) {
		cout << (s.size() * k) / 2 << endl;
	}
	else {
		if (a % 2 == 1 && b % 2 == 1 && s[0] == s[s.size() - 1]) {
			ans += k - 1;
		}
		cout << ans << endl;
	}
}

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

template <typename T> struct SegmentTree {
  struct Node {
    T v;
    Node(T v) : v(v) {}

    Node operator*(const Node &r) const {
      return Node(min(v, r.v));
    }
  };

  Node e = Node((1ll << 31) - 1);
  size_t sz;
  vector<Node> seg;

  SegmentTree(int n) {
    sz = 1;
    while (sz < n) sz <<= 1;
    seg.assign(2 * sz - 1, e);
  }

  void update(int k, const Node &x) {
    k += sz - 1;
    seg[k] = x;
    while (k) {
      k = (k - 1) / 2;
      seg[k] = seg[2 * k + 1] * seg[2 * k + 2];
    }
  }

  Node query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return e;
    if (a <= l && r <= b) return seg[k];
    return query(a, b, 2 * k + 1, l, (l + r) / 2) * query(a, b, 2 * k + 2, (l + r) / 2, r);
  }

  void update(int k, T x) {
    update(k, Node(x));
  }

  T query(int a, int b) {
    return query(a, b, 0, 0, sz).v;
  }
};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A&lang=jp
int main() {
  int n, q;
  cin >> n >> q;

  SegmentTree<int> seg(n);
  while (q--) {
    int com;
    cin >> com;

    if (com) {
      int l, r;
      cin >> l >> r;
      cout << seg.query(l, r + 1) << '\n';
    } else {
      int v, x;
      cin >> v >> x;
      seg.update(v, x);
    }
  }
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;

    if (abs(n - m) >= 2) {
        put(0);
        return 0;
    }

    ll MOD = 1000000007;
    ll N = 1;
    repi(i, n + 1) N = (N * i) % MOD;
    ll M = 1;
    repi(i, m + 1) M = (M * i) % MOD;

    if (abs(n - m) == 1) {
        // n! * m!;
        put((N * M) % MOD);
    }
    else {
            put(( ((2 * N) % MOD) * M) % MOD);
    }
    return 0;
}

Measured memory_bytes: 3544
#include <iostream>
using namespace std;
string S[1000];
int N;
int main(){
  cin >> N;
  bool judge = true;
  for(int i=0;i<N;i++){
	cin >> S[i];
    if(i>=1){
		if(S[i][0]!=S[i-1][S[i-1].size()-1]) judge = false;
    }
  }
  for(int i=0;i<N-1;i++){
	for(int j=i+1;j<N;j++){
      if(S[i]==S[j]) judge = false;
    }
  }
  cout << (judge? "Yes":"No") << endl;
}
  


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
typedef vector<P> Pol;
D eps=1e-9,inf=1e9;
int A,n[100];
Pol pol[100];
P s,t;
L l;
bool eq(D a,D b){return abs(a-b)<eps;}
int sig(D a){return eq(a,0)?0:(a>0?1:-1);}
D cro(P a,P b){return imag(conj(a)*b);}
D dot(P a,P b){return real(conj(a)*b);}
int ccw(P a,P b,P c){
	if(sig(cro(b-a,c-a))==1) return 1;
	if(sig(cro(b-a,c-a))==-1) return -1;
	if(eq(abs(a-c)+abs(c-b),abs(a-b))) return 0;
	if(eq(abs(a-b)+abs(c-b),abs(a-c))) return -2;
	return 2;
}
int ccw(L a,P p){return ccw(a.fs,a.sc,p);}
P intLL(L a,L b){
	D t=cro(a.sc-a.fs,a.sc-b.fs)/cro(a.sc-a.fs,b.sc-b.fs);
	return b.fs+t*(b.sc-b.fs);
}
bool contain(Pol pol,P p){
	bool in=0;
	int N=pol.size();
	rep(i,N){
		P a=pol[i]-p,b=pol[(i+1)%N]-p;
		if(ccw(a,b,P(0,0))==0) return 1;
		if(imag(a)>imag(b)) swap(a,b);
		if(sig(imag(a))<=0&&0<sig(imag(b))&&ccw(P(0,0),a,b)==1) in=!in;
	}
	return in;
}
P perp(L l,P p){
	D t=dot(p-l.fs,l.fs-l.sc)/norm(l.fs-l.sc);
	return l.fs+t*(l.fs-l.sc);
}
P refl(L l,P p){
	return p+2.0*(perp(l,p)-p);
}
bool ispal(L a,L b){
	return sig(cro(a.fs-a.sc,b.fs-b.sc))==0;
}
bool iSS(L a,L b){
	return ccw(a,b.fs)*ccw(a,b.sc)<=0&&ccw(b,a.fs)*ccw(b,a.sc)<=0;
}
L BL;
bool compBL(const P& a,const P& b){			//BL?????????????????????(BL.fs??´????°???????)
	return dot(l.sc-l.fs,a-l.fs)<dot(l.sc-l.fs,b-l.fs);
}
bool containE(Pol pol,L l){
	vector<P> ps;
	ps.pb(l.fs);
	ps.pb(l.sc);
	int N=pol.size();
	rep(i,N){
		L a(pol[i],pol[(i+1)%N]);
		if(ispal(a,l)) continue;
		if(!ispal(a,l)&&iSS(a,l)) ps.pb(intLL(a,l));
	}
	BL=l;
	sort(all(ps),compBL);
	int K=ps.size();
	rep(i,K-1) ps.pb((ps[i]+ps[i+1])/2.0);
	for(P p:ps) if(!contain(pol,p)) return 0;
	return 1;
}
int main(){
	while(true){
		cin>>A;
		if(A==0) break;
		rep(i,A){
			pol[i].clear();
			cin>>n[i];
			rep(j,n[i]){
				int x,y;
				cin>>x>>y;
				pol[i].pb(P(x,y));
			}
		}
		{
			int a,b,c,d;
			cin>>a>>b>>c>>d;
			s=P(a,b),t=P(c,d);
			cin>>a>>b>>c>>d;
			l=L(P(a,b),P(c,d));
		}
		int a=-1,b=-1,c=-1,d=-1;
		rep(i,A){
			if(contain(pol[i],s)) a=i;
			if(contain(pol[i],t)) b=i;
			if(contain(pol[i],refl(l,s))) c=i;
			if(contain(pol[i],refl(l,t))) d=i;
		}
		if(a<0||b<0||c<0||d<0||a!=b||c!=d){
			puts("impossible");
			continue;
		}
		Pol e=pol[a],f=pol[c];
		int E=e.size(),F=f.size();
		rep(i,F/2) swap(f[i],f[F-1-i]);
		rep(i,F) f[i]=refl(l,f[i]);
		Pol ps;
		ps.pb(s);
		ps.pb(t);
		for(P p:e) ps.pb(p);
		for(P p:f) ps.pb(p);
		int N=ps.size();
		D dis[102][102]={};
		rep(i,N) rep(j,N) if(i!=j){
			dis[i][j]=inf;
			if(containE(e,L(ps[i],ps[j]))&&containE(f,L(ps[i],ps[j]))) dis[i][j]=abs(ps[i]-ps[j]);
		}
		rep(i,N) rep(j,N) rep(k,N) chmin(dis[j][k],dis[j][i]+dis[i][k]);
		if(dis[0][1]==inf) puts("impossible");
		else printf("%.12f\n",dis[0][1]);
	}
}

Measured memory_bytes: 3312
#include<stdio.h>
#define MAX 100
#define INFTY 99999999
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,i,j,M[MAX][MAX];

void dijkstra(){
  int minv,v;
  int d[MAX], color[MAX];

  for(i = 0 ; i < n ; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INFTY;
    int u = -1;
    for(i = 0 ; i < n ; i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1)break;
    color[u] = BLACK;
    for(v = 0 ; v < n ; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > d[u] + M[u][v]){
	  d[v] = d[u] + M[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  for(i = 0 ; i < n ; i++){
    printf("%d %d\n",i,(d[i] == INFTY ? -1 : d[i]));
  }
}

int main(){
  scanf("%d",&n);
    for(i = 0 ; i < n ; i++){
      for(j = 0 ; j < n ; j++){
	M[i][j] = INFTY;
      }
    }
    int k, c, u,v;
  for(i = 0 ; i < n ; i++ ){
    scanf("%d%d",&u,&k);
    for(j = 0 ; j < k ; j++){
      scanf("%d%d",&v,&c);
      M[u][v] = c;
    }
      }
  dijkstra();
  return 0;
}



Measured memory_bytes: 2048
//No matter how imaginary the dreams are, i over i is always real!
//#include <boost/multiprecision/cpp_int.hpp> 
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
typedef double db;
// __int128 s128;
// __uint128_t u128;
typedef unsigned long long u64;
#define int long long int
#define P 1000000007
#define Q 1000000006
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define N 3000
#define PI 3.14159265359
#define inf LLONG_MAX
//using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;

void solve(){
    ll n,sum=0;
    cin>>n;
    vl a(n+1);
    ll dp[n+1][n+1] = {};
    f(i,1,n+1) cin>>a[i], dp[i][i]=a[i], sum += a[i];
    f(d,1,n){
        f(i,1,n-d+1){
            ll j = i+d;
            ll p1=0, p2=0, p3=0, p4=0;

            if(i+2<=j) p1 = dp[i+2][j];
            if(j-1>=i+1) p2 = dp[i+1][j-1];
            if(j-2>=i) p3 = dp[i][j-2];

            ll left = a[i] + min(p1, p2);
            ll right = a[j] + min(p3, p2);

            dp[i][j] = max(left,right);
        }
    }
    cout<<2*dp[1][n] - sum;
}
signed main() {
    teevra_gati
        
    solve();

    return 0;
}

Measured memory_bytes: 70656
import java.util.Scanner;

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

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

        if(a<b){
            if(b<=c){
                System.out.printf("%d %d %d\n",a,b,c);
            }else if(a>=c){
                System.out.printf("%d %d %d\n",c,a,b);
            }else if(a<c && c<b){
                System.out.printf("%d %d %d\n",a,c,b);
            }
        }else{
            if (a <=c) {
                System.out.printf("%d %d %d\n", b, a, c);
            } else if (b >=c) {
                System.out.printf("%d %d %d\n", c, b, a);
            }else if(b<c && c<a){
                System.out.printf("%d %d %d\n",b,c,a);
            }
        }
    }
}


Measured memory_bytes: 26452
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = a[0]-1, d = 2;
  for (int i = 1; i < n; i++) {
    if (a[i] < d)
      continue;
    if (a[i] == d)
      d = a[i]+1;
    else
      ans += (a[i]-1)/d;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3996
import sys
import math
import time
sys.setrecursionlimit(int(1e6))
if False:
    dprint = print
else:
    def dprint(*args):
        pass

k = list(map(int, input().split()))[0]

modk = 7 % k
i = 1
while(i < k):
    if modk == 0:
        print(i)
        exit()

    i += 1
    modk = (modk * 10 + 7) % k
else:
    if modk == 0:
        print(i)
    else:
        print(-1)


Measured memory_bytes: 9188
#include<stdio.h>
#include<math.h>
int main(){
	int n,i;
	int t0=0,x0=0,y0=0,t,x,y,flag=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d%d%d",&t,&x,&y);
		if(abs(x-x0)+abs(y-y0)<=abs(t-t0)&&(abs(t-t0)-abs(x-x0)+abs(y-y0))%2==0){
			flag++;
			x0=x;
			y0=y;
			t0=t;
		}
	}
	if(flag==n)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
 
#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
 
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
 
    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    ll k;
    ll h,w;
    cin>>h>>w>>a>>b;
    string s[h];
    rep(i,h){
        rep(j,w){
            if(i<b&&j<a||i>=b&&j>=a) cout<<1;
            else cout<<0;
        }
        ln;
    }

    
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h> 
    #include<ext/pb_ds/assoc_container.hpp> 
    #include<ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
    #define int long long  
    typedef long double ld;
    #define pb push_back
    #define f(i,a,b) for(int i=a;i<b;i++)
    #define fd(i,a,b) for(int i=a-1;i>=b;i--)
    #define pf push_front
    #define fi first
    #define se second
    #define INF 1e10
    const double pi=3.14159265358979323;
    const int mod=998244353;
    const int MAX=1e7+5;
    int gcd(int a, int b) 
    { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
    } 
    void swap(int a,int b)
    {
      int temp=a;
      a=b;
      b=temp;
    } 
    int  binpow(int  a,int  b) 
    {
    int res = 1;
    while (b > 0) {
        if (b%2 == 1)
            res = (res * a)%mod;
        a = (a* a)% mod;
        b >>= 1;
    }
    return res;
}
    int modinv(int y)
    {
        return binpow(y,mod-2);
    }
 
    int fact[500000+5];
    void precal()
    {
    fact[0]=1;
    for(int i=1;i<500000+5;i++)
    {
        fact[i]=(i*fact[i-1])%mod;
    }
}   
    bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
   
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
    signed main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    #ifndef ONLINE_JUDGE
     if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout); 
      }
    #endif  
    // -------------------------------------Code starts here--------------------------------------------------------------------- 
    int t=1; 
    //cin>>t;
    while(t--)
    {
        int n,m,k;
        cin>>n>>m>>k;
        int a[n+1],b[m+1];
        f(i,0,n)
        cin>>a[i];
        f(i,0,m)
        cin>>b[i];
        vector<int > p1,p2;
        p1.pb(0);
        p1.pb(a[0]);
        f(i,1,n)
        {
            int x=p1.back();
            p1.pb(x+a[i]);
        }
        p2.pb(0);
        p2.pb(b[0]);
        f(i,1,m)
        {
            int x=p2.back();
            p2.pb(x+b[i]);
        }
        int mx=0;
        int j=p2.size()-1;
        f(i,0,p1.size())
        {
            if(p1[i]>k)
                break;
            while(p2[j]>k-p1[i])
            {
                j-=1;
            }
            mx=max(mx,i+j);
        }
        cout<<mx<<endl;
    }
}

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

#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define pfis(a) printf("%d ",a);
#define pfls(a) printf("%lld ",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(int i=a;i<b;i++)
#define pb(a) push_back(a);
#define mp(a,b) make_pair(a,b)
#define ll long long
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>

const ll mod=1e9+7;

void solve()
{
    ll n;
    sfl(n)
    
    vi ans;

    while(n>0)
    {
    	n--;
    	ans.pb(n%26)
    	n/=26;
    }

   	reverse(ans.begin(),ans.end());

   	vc str;

   	for(auto itr:ans)
   	{
   		char ch=itr+'a';
   		str.pb(ch)
   	}

   	for(auto itr:str)
   		cout<<itr;

    return;
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    solve();
    
    return 0;
}

Measured memory_bytes: 3592
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int A = sc.nextInt();
   int B = sc.nextInt();
   int X = sc.nextInt();
 
   if((B-A)/2 +1 <=X)
   {
     for(int i = A;i<=B;i++)
     {
       System.out.println(i);
     }
   }
   else
   {
     for(int i =A;i<=A+X-1;i++)
     {
       System.out.println(i); 
     }
     for(int i =B-X+1;i<=B;i++)
     {
       System.out.println(i);
     }
   }
 }
}

Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, g, b, n; cin >> r >> g >> b >> n;
    ll ans = 0;
    for(int i = 0; i <= 3000; i++)
    {
        for(int j = 0; j <= 3000; j++)
        {
            //k bo-ru
            ll k = n - i * r - j * g;
            if(k < 0) continue;;
            if(k % b != 0) continue;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
#define N (ll)(1e6+3)
#define INF (ll)(1e18+3)
#define MOD (ll)(1e9+7)
 
#define ll long long
#define rep(i,a,n) for(ll i = a; i < n; i++)
#define per(i,a,n) for(ll i = n-1; i >= a; i--)
 
//using namespace __gnu_pbds;
using namespace std;
 
// typedef
// tree<
//     pair<ll,ll>,
//     null_type,
//     less<pair<ll,ll>>,
//     rb_tree_tag,
//     tree_order_statistics_node_update>
// ordered_set;



void solve() {
    ll n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    vector<bool> v(n);
    rep(i,0,n)
        v[i] = a[i] == b[i];
    ll ans = 1, last = 0;

    rep(i,0,n) {
        if (i == 0) {
            if (v[i]) {
                ans = 3;
            }
            else {
                ans = 6;
                i++;
            }
        }
        else {
            if (v[i]) {
                if (last)
                    ans = (ans*2)%MOD;
            }
            else {
                if (last)
                    ans = (ans*2)%MOD;
                else
                    ans = (ans*3)%MOD;
                i++;
            }
        }
        last = v[i];
    }

    cout << ans << endl;
}
 
int main() {
    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int f1=s.length();
	int f2=t.length();
	if(t.substr(0,f1)==s && f2==f1+1){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#define long long long
using namespace std;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;


signed main()
{
  cin.tie(nullptr), ios::sync_with_stdio(false);
  string s;
  cin >> s;
  cout << count(s.begin(), s.end(), '2') << endl;

  return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    char c;
    cin >> c;
    char ans = 'G';
    if (c == 'A')ans = 'T';
    else if (c == 'T')ans = 'A';
    else if (c == 'G')ans = 'C';
    cout << ans << endl;
    return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define foru(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define endl "\n"
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define com(a, b) a ## b
#define scv(a, b, c) #a#b#c
#define db(x) cerr << "[" << #x << ": " << (x) << "] " << endl;
#define run cerr << 1 << endl; 
template<class T> void printvec(vector<T>& x, int a, int b) {foru (i, a, b) cout << x[i] << " "; cout << endl;}

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<pll> v2l;
typedef pair<char, int> pci;
typedef vector<pci> vci;

const ld PI = acos((ld) -1);
const ld EPS = 1e-6;
const int N = 1e6 + 1;
const int NN = 1e3 + 1;
const ll MOD = 1e9 + 7;
const ll oo = 1e18 + 7;
const int BASE = 10000;

void solve() {
    string c = "RGB";
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<vi> cnt(n + 1, vi(3));
    for (int i = 0; i < n; i++) {
        cnt[i + 1] = cnt[i];
        for (int j = 0; j < 3; j++) {
            if (s[i] == c[j]) {
                cnt[i + 1][j]++;
            }
        }
    }
    ll res = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            if (s[i - 1] == s[j - 1]) {
                continue;
            }
            vi check(3);
            for (int k = 0; k < 3; k++) {
                if (s[i - 1] == c[k]) {
                    check[k] = 1;
                }
                if (s[j - 1] == c[k]) {
                    check[k] = 1;
                }
            }
            int pos = -1;
            for (int k = 0; k < 3; k++) {
                if (!check[k]) {
                    pos = k;
                    break;
                }
            }
            res += cnt[i - 1][pos] - (s[2 * i - j - 1] == c[pos]);
        }
    }
    cout << res;
}

int main() {
    #ifdef DEBUG
        com(fre, open) (scv(solve, ., inp), "r", stdin);
        com(fre, open) (scv(solve, ., out), "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
} 

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

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

		Scanner scan = new Scanner(System.in);

		Stack<Integer> garage = new Stack<Integer>();
		while ((scan.hasNext())) {
			int num = scan.nextInt();
			if (num != 0) {
				garage.push(num);
			} else {
				System.out.println(garage.pop());
			}

		}
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 998244353;
const int N = 3006;
const ll INF = 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if(s.back() == 's') {
        s += "es";
    } else {
        s += "s";
    } 
    cout << s << '\n';
    
    return 0;
}

Measured memory_bytes: 3644
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int s = scanner.nextInt();
			Set<Integer> set = new HashSet<>();
			int now = s, prev = -1, count = 1;
			while (!set.contains(now)) {
				set.add(now);
				prev = now;
				now = f(prev);
				count++;
			}
			System.out.println(count);
		}
	}

	/**
	 * f(n)を計算する
	 * 
	 * @param n
	 * @return f(n)
	 */
	private static int f(int n) {
		return (0 == (n & 1)) ? n / 2 : 3 * n + 1;
	}
}


Measured memory_bytes: 35636
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int m;
  cin >> m;
  long long sum = 0, digs = 0;
  for (int i = 0; i < m; i++) {
    long long d, c;
    cin >> d >> c;
    sum += d * c;
    digs += c;
  }
  cout << (sum - 1) / 9 + digs - 1 << '\n';
  return 0;
}

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

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

const int INF = 1e9 + 7;

using namespace std;

void judge_i(char c, int& one, int& zero) {
   if (c == '1')
	one++;
    else
	zero++;
}

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

    string s;
    cin >> s;


    int one_num = 0;
    int zero_num = 0;
    int res = 0;

    char now = s[0];
    judge_i(now, one_num, zero_num);

    rep (i, 1, s.size()) {
	if (one_num == 0 && zero_num == 0) {
	    now = s[min(i, (int)s.size() - 1)];
	    judge_i(now, one_num, zero_num);
	    continue;
	}

	judge_i(s[i], one_num, zero_num);

	if (s[i] != now) {
	    one_num--;
	    zero_num--;
	    res += 2;
	} 
    }

    cout << res << endl;
    
    return 0;
}


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

namespace ABC096_D___Five__Five_Everywhere
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var isPrime = new bool[55556];
            for (int i = 2; i <= 55555; i++) isPrime[i] = true;
            for (int i = 2; i <= 55555; i++)
            {
                if (!isPrime[i]) continue;
                for (int j = i * 2; j <= 55555; j += i) isPrime[j] = false;
            }
            var primes = new List<int>();
            for (int i = 2; i <= 55555; i++) if (isPrime[i]) primes.Add(i);
            var answer = primes.Where(s => s % 5 == 1).Take(N).ToArray();
            Console.WriteLine(string.Join(" ", answer));
        }
    }
}


Measured memory_bytes: 13392
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String[] tmpArray = br.readLine().split(" ");
			int num = Integer.parseInt(tmpArray[0]);
			int len = Integer.parseInt(tmpArray[1]);
			
			
			if(num == 0 && len == 0){
				break;
			}
			
//			System.out.println("max "+maxDecimal(num, len));
//			System.out.println("min "+minDecimal(num, len));
			
			HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
			map.put(num, 0);
			int i = 1;
			while(true){
				int maxnum = maxDecimal(num, len);
				int minnum = minDecimal(num, len);
//				
//				System.out.println("max "+maxDecimal(num, len));
//				System.out.println("min "+minDecimal(num, len));
				
				num = maxnum - minnum;
				if(map.containsKey(num)){
					System.out.println(map.get(num)+" "+ num+" "+( i - map.get(num)));
					break;
				}
				else {
					map.put(num, i);
				}
				i++;
			}
		}
	}
	
	static int maxDecimal(int num, int len){
		String tmpStr = Integer.toString(num);
		char[] carray = tmpStr.toCharArray();
		Arrays.sort(carray);
		StringBuffer sb = new StringBuffer(new String(carray));
		
		int tmpResult = Integer.parseInt(sb.reverse().toString());
		
		if(sb.length() < len){
			tmpResult *= Math.pow(10, len - sb.length());
		}
		
		return tmpResult;
	}
	
	static int minDecimal(int num, int len){
		String tmpStr = Integer.toString(num);
		char[] carray = tmpStr.toCharArray();
		Arrays.sort(carray);
		StringBuffer sb = new StringBuffer(new String(carray));
		
		int tmpResult = Integer.parseInt(sb.toString());
			
		return tmpResult;
	}

}

Measured memory_bytes: 26308
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] perm = new int[n + 1];
        int steps = 0;

        for (int i = 1; i < perm.length; i++) perm[i] = scanner.nextInt();
        if (perm[1] == 1){
            swap(perm, 1, 2);
            steps++;
        }
        for (int i = 2; i < perm.length; i++) {
//            System.out.println(Arrays.toString(perm));
            if (i <= perm.length - 2 && perm[i] == i && perm[i + 1] == (i + 1)){
                swap(perm, i, i + 1);
                steps++;
            }
            else if (perm[i] == i){
                swap(perm, i, i - 1);
                steps++;
            }
        }

        System.out.println(steps);
    }

    private static void swap(int[] arr, int i, int j){
        int temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }
}


Measured memory_bytes: 49120
#include <iostream>
using namespace std;
int main() {
    int N, A, B, acnt = 0, bcnt = 0;
    cin >> N >> A >> B;
    char c;
    for (int i = 0; i < N; i++) {
        cin >> c;
        if (c == 'a') {
            if (acnt + bcnt < A + B) {
                acnt++;
                cout << "Yes" << endl;
            }
            else cout << "No" << endl;
        }
        else if (c == 'b') {
            if (acnt + bcnt < A + B && bcnt < B) {
                bcnt++;
                cout << "Yes" << endl;
            }
            else cout << "No" << endl;
        }
        else cout << "No" << endl;
    }
}


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

int main()
{

	long long N, X, Y;
	cin >> N >> X >> Y;

	vector<long long> A(N);

	long long i, j;

	for (i = 1; i <= N-1; ++i) {
		for (j = i + 1; j <= N; ++j) {
			if (i <= X && j >= Y) {
				++A.at(j - i - (Y - X) + 1);
			}
			else if (i > X && j >= Y) {
				++A.at(min(i - X + 1 + j - Y, j - i));
			}
			else if (i <= X && j < Y) {
				++A.at(min(X - i + 1 + Y - j, j - i));
			}
			else {
				++A.at(min(j - i,i - X + 1 + Y - j));
			}
		}
	}

	for (i = 1; i <= N-1; ++i) {
		cout << A.at(i) << endl;
	}

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

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

		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int N = sc.nextInt(), M = sc.nextInt(), fav[][] = new int[N][M];
		for(int i = 0; i < N; ++i)
			for(int j = 0; j < M; ++j)
				fav[i][j] = sc.nextInt() - 1;
		int[] cnt = new int[M];
		for(int i = 0; i < N; ++i)
			cnt[fav[i][0]]++;
		int ans = N, ptr[] = new int[N];
		for(int k = 0; k + 1 < M; ++k)
		{
			int max = -1, idx = -1;
			for(int i = 0; i < M; ++i)
				if(cnt[i] > max)
					max = cnt[idx = i];

			ans = Math.min(ans, max);
			cnt[idx] = -1;
			for(int i = 0; i < N; ++i)
			{	
				cnt[fav[i][ptr[i]]]--;
				while(cnt[fav[i][ptr[i]]] < 0)
					++ptr[i];
				cnt[fav[i][ptr[i]]]++;
			}
		}
		out.println(ans);
		out.close();
	}

	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public Scanner(String s) throws FileNotFoundException{	br = new BufferedReader(new FileReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException { return Double.parseDouble(next()); }

		public boolean ready() throws IOException {return br.ready();} 
	}
}

Measured memory_bytes: 31404
import math
ab = [int(i) for i in input().split()]
ab = math.gcd(ab[0], ab[1])
dic = {}
n = 2
while n**2 <= ab:
  if ab % n:
    n += 1
  else:
    ab //= n
    dic[n] = dic.get(n,0) + 1
if 1 < ab:
  dic[ab] = dic.get(ab,0) + 1

print(len(dic) + 1)

Measured memory_bytes: 9180
#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(i,0,n)
#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;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    string st;
    cin>>st;
    int ans=INF;
    REP(i,(int)st.size()-2){
        chmin(ans,abs(753-stoi(st.substr(i,3))));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
 
 
using namespace std;
 
int main()
{
    int n;
    cin>>n;
    vector<int> A(n),B(n),C(n);
    rep(i,n){
        cin>>A[i];
    }
    rep(i,n){
        cin>>B[i];
    }
    rep(i,n-1){
        cin>>C[i];
    }
    int sum = 0;
    rep(i,n){
        sum = sum + B[A[i]-1];
        if((A[i]-A[i-1])==1){
            sum = sum + C[A[i]-2];
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3592
import math
a,b,h,m=input().split()
a=float(a)
b=float(b)
h=float(h)
m=float(m)
pi=math.pi
rad=2*pi*(h/12+m/60/12-m/60)
ans=(a*a)+(b*b)-2*a*b*math.cos(rad)
print(math.sqrt(ans))

Measured memory_bytes: 9276
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    int ans = 0;
    int now=1;
    while(now<b){
        now+=a-1;
        ans++;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(void)
{
	int n;
	string s;
	string ans;
	char temp;

	int i1,i2;

	while(1){
		cin>>n;
		if(n==0) break;

		vector<int> k(n);

		for(i1=0;i1<n;i1++){
			cin>>k[i1];
		}
		cin>>s;

		ans="";
		for(i1=0;i1<s.size();i1++){
			temp=s[i1];
			for(i2=0;i2<k[i1%n];i2++){
				temp--;
				if(temp==('a'-1)) temp='Z';
				if(temp==('A'-1)) temp='z';
			}
			ans+=temp;
		}

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

Measured memory_bytes: 1204
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000000
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int H, W;
queue<pair<int, int>> det;
vector<vector<int>> mv(1000, vector<int>(1000, INF));
int ans = 0;

void bfs(int x, int y, int d){
  if(x < 0 || x >= H || y < 0 || y >= W){
    return;
  }
  if(mv.at(x).at(y) < INF){
    return;
  }
  mv.at(x).at(y) = d + 1;
  chmax(ans, d+1);
  det.push(make_pair(x, y));
}

int main(){
  cin >> H >> W;
  vector<string> A(H);
  rep(i, H){
    cin >> A.at(i);
  }
  vector<pair<int, int>> s;
  rep(i, H){
    rep(j, W){
      if(A.at(i).at(j) == '#'){
        s.push_back(make_pair(i, j));
      }
    }
  }
  rep(k, sz(s)){
    bfs(s.at(k).first, s.at(k).second, -1);
  }

  while(!det.empty()){
    pair<int, int> q = make_pair(det.front().first, det.front().second);
    det.pop();
    int d = mv.at(q.first).at(q.second);
    bfs(q.first+1, q.second, d);
    bfs(q.first-1, q.second, d);
    bfs(q.first, q.second+1, d);
    bfs(q.first, q.second-1, d);
  }
  cout << ans << endl;
}

Measured memory_bytes: 21232
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
#include <map>
#include <utility>
//using
using namespace std;
using vi = vector <int>;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
 //各位の和　
int wa(ll x)
{
ll sum = 0;
while(x!=0){
  sum += x% 10;
  x /= 10;
}
return sum;
}
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文
//if(isupper('A'))->大なら真


//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  ll n;
  cin>>n;
  vl a(3*n);
  rep(i,3*n)
  {
    cin>>a[i];
  }
  sortm(a);
  rep(i,2*n)
  {
    if(i%2==1)
    {
      p+=a[i];
    }
  }

  print(p);
}

Measured memory_bytes: 5584
#include<iostream>
using namespace std;
int a[100],b[100],c[100],ans;
int main()
{
  int N;
  cin>>N;
  for(int i=0;i<N;i++)
    cin>>a[i],
  a[i]--;
  for(int i=0;i<N;i++)
    cin>>b[i];
  for(int i=0;i<N-1;i++)
    cin>>c[i];
  for(int i=0;i<N;i++)
  {
    ans+=b[a[i]];
    if(i&&a[i]-1==a[i-1])
      	ans+=c[a[i-1]];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

int main(){
	int n;
	int cnt = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if ((t & 1 == 1 && t != 1) || t == 2) {// （奇数かつ1でない）または2であるなら
			int m = sqrt((double)t);
			int j = 3;
			while (j <= m) {
				if (t % j == 0) { // 素数でないなら
					break;
				}
				j += 2;
			}
			if (j > m) { // 素数であるなら
				cnt++;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int n;
const int maxN = 3 * (int)1e4 + 10;
bool ok[maxN];
vector < int > pr;
bool get_[100];
bool used[maxN];
bool vis[maxN];
int main() {
    srand(time(0));
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    for (int i = 2; i < 7; i++) {
        if (get_[i]) continue;
        pr.push_back(i);
        for (int j = 2 * i; j < 7; j += i) get_[j] = true;
    }
    cin >> n;
    for (int j = 0; j < pr.size(); j++) {
        int p = pr[j];
        for (int k = p; k < maxN; k += p) ok[k] = true;
    }
    int cur = 0;
    int sum = 0;
    vector < int > ans;
    for (int i = 1; i < maxN; i++) {
        if (cur == n - 1) break;
        if (ok[i]) {
            used[i] = true;
            sum += i;
            ans.push_back(i);
            cur++;
        }
    }
    //for (int j = 0; j < pr.size(); j++) cout << pr[j] << " ";
    //cout << sum << endl;
    while (ans.size() != n) {
        //for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
        //cout << endl;
        for (int i = 3 * (int)1e4; i >= 3 * (int)1e4 - 1000; i--) {
            int t = sum + i;
            if (!ok[i]) continue;
            if (used[i]) continue;
            bool okk = true;
            for (int j = 0; j < pr.size(); j++) {
                if ((t % pr[j]) != 0) {
                    okk = false;
                    break;
                }
            }
            if (okk) {
                ans.push_back(i);
                break;
            }
        }
        if (ans.size() != n) {
            used[ans.back()] = false;
            sum -= ans.back();
            ans.pop_back();
            for (int j = 3 * (int)1e4; ;j--) {
                if (ok[j] && !used[j]) {
                    if (vis[j]) continue;
                    vis[j] = true;
                    ans.push_back(j);
                    used[j] = true;
                    sum += j;
                    break;
                }
            }
        }
    }
    for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <assert.h>

using namespace std;

#define MAXN 21
long long MM =(1e9+7);


int A[MAXN+1][MAXN+1];


int number_1_bit(int set) {
  int count = 0;
  while (set != 0) {
    count += (set & 1);
    set = set >> 1;
  }

  return count;
}

int main() {
  // task O
  assert( (1 << 1) == 2);

  assert( number_1_bit(7) == 3 );
  assert( number_1_bit(8) == 1 );
  assert( number_1_bit(0) == 0 );
  assert( number_1_bit(0b101010100) == 4 );
  assert( number_1_bit(0b001010100) == 3 );

  int N;
  cin >> N;
  assert(N > 0 && N <= 21);
  // count from 0 -> N-1
  for(auto i=0;i<N; i++) {
    for(auto j=0;j<N; j++) cin >> A[i][j];
  }

  vector<int> F( (1<<N) + 1, 0);

  F[0] = 1; // there is a way to match two empty sets

  for (int subset = 1; subset < (1 << N); subset++) {
    auto size = number_1_bit(subset);
    // matching subset (women) with the set {0 .. |subset|-1} (men)

    for (auto i=0; i<N; i++) { // consider matching (size-1)-th man <-> i-th bit woman
      if(  subset & (1<<i) ) { // in the subset
        if ( A[size-1][ i ] == 1) {  // a match, consider a sub problem, disable i-th bit
          auto sub = subset - (1<<i);
          F[subset] = (F[subset] + F[sub]) % MM;
        }
      }
    }
  }

  cout << F[ (1<<N) - 1] << endl;
  return 0;
}

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

#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;

        int count = 0;
    rep(i, n - 2)
    {

        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256