akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
	int a,b,x,i=2,total=0;
	float t;
	scanf("%d %d %f", &a, &b, &t);
	x=a;
	while(x<=t+0.5){
		total+=b;
		x=i*a;
		i++;
	}
	printf("%d\n", total);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))
C = {1:0,2:0,3:0}
for i in range(N):
    if P[i]<=A:
        C[1] += 1
    elif P[i]<=B:
        C[2] += 1
    else:
        C[3] += 1
print(min(C[1],C[2],C[3]))

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void inline swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void inline swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

typedef pair<ll, int> P;
vector<vector<pair<ll, int>>> g;
vector<tupiii> loc;
int n;


void init()
{
	cin >> n;
	g.resize(n);
	loc.resize(n);

	REP(i, n)
	{
		int a, b; cin >> a >> b;
		loc[i] = tupiii(a, b, i);
	}

	sort(ALL(loc), [](const tupiii& left, const tupiii& right) { return get<0>(left) < get<0>(right); });

	REP(i, n - 1)
	{
		g[get<2>(loc[i])].emplace_back(MP(abs(get<0>(loc[i + 1]) - get<0>(loc[i])), get<2>(loc[i + 1])));
		g[get<2>(loc[i + 1])].emplace_back(MP(abs(get<0>(loc[i + 1]) - get<0>(loc[i])), get<2>(loc[i])));
	}

	sort(ALL(loc), [](const tupiii& left, const tupiii& right) { return get<1>(left) < get<1>(right); });

	REP(i, n - 1)
	{
		g[get<2>(loc[i])].emplace_back(MP(abs(get<1>(loc[i + 1]) - get<1>(loc[i])), get<2>(loc[i + 1])));
		g[get<2>(loc[i + 1])].emplace_back(MP(abs(get<1>(loc[i + 1]) - get<1>(loc[i])), get<2>(loc[i])));
	}

}

ll Prim()
{
	vector<bool> done(n, false);
	ll tot = 0;

	REP(i, n)
	{
		if (!done[i])
		{
			priority_queue<P, vector<P>, greater<P>> que;
			que.push(MP(0LL, i));

			while (!que.empty())
			{
				int v = que.top().second;
				ll c = que.top().first;
				que.pop();

				if (!done[v])
				{
					done[v] = true;
					tot += c;

					for (P adj : g[v])
						que.push(adj);
				}
			}
		}
	}

	return tot;
}


int main()
{
	init();

	ll ans = Prim();

	cout << ans << endl;

}


Measured memory_bytes: 18800
s = []
j = 0
num = 0

n,k = map(int, input().split())
for i in range(k):
  d = int(input())
  s.extend(input().split())

s = list(set(s))
for j in range(n):
  p = str(j + 1)
  if p in s:
    num += 1

print(n - num)

Measured memory_bytes: 9532
w, h, n = [int(x) for x in input().split()]
c = [[0, 0], [w, h]]
for _ in range(n):
    x, y, a = [int(x) for x in input().split()]
    if a == 1:
        if c[0][0] <= x and x <= c[1][0]:
            c[0][0] = x
        elif c[1][0] <= x:
            c[0][0] = c[1][0]
    elif a == 2:
        if c[0][0] <= x and x <= c[1][0]:
            c[1][0] = x
        elif x <= c[0][0]:
            c[1][0] = c[0][0]
    elif a == 3:
        if c[0][1] <= y and y <= c[1][1]:
            c[0][1] = y
        elif c[1][1] <= y:
            c[0][1] = c[1][1]
    elif a == 4:
        if c[0][1] <= y and y <= c[1][1]:
            c[1][1] = y
        elif y <= c[0][1]:
            c[1][1] = c[0][1]
print((c[1][0]-c[0][0])*(c[1][1]-c[0][1]))

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

string joi(int lv){
  string s = "";
  for(int i = 0;i < lv;i++) s += 'J';
  for(int i = 0;i < lv;i++) s += 'O';
  for(int i = 0;i < lv;i++) s += 'I';
  return s;
}

int main(){
  string s;
  vector<pair<int,int> > os;
  cin >> s;
  int cnt = 0,start;
  for(int i = 0;i < s.length();i++){
    if(s[i] == 'O'){
      if(cnt == 0) start = i;
      cnt++;
    }
    else if(cnt != 0) {
      os.push_back(make_pair(start,cnt));
      cnt = 0;
    }
  }
  int maxlv = 0;
  for(int i = 0;i < os.size();i++){
    if(os[i].second > os[i].first || os[i].first + os[i].second * 2 > s.length()) continue;
    if(os[i].second <= maxlv) continue;
    bool flag = true;
    for(int j = os[i].first - os[i].second;j < os[i].first;j++){
      if(s[j] != 'J'){
	flag = false;
	break;
      }
    }
    if(!flag) continue;
    for(int j = os[i].first + os[i].second;j < os[i].first + os[i].second * 2;j++){
      if(s[j] != 'I'){
	flag = false;
	break;
      }
    }
    if(flag) maxlv = os[i].second;
  }
  cout << maxlv << endl;
  return 0;
}

Measured memory_bytes: 8480
using System;
using static System.Console;
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace atcoder
{
    class Program
    {
        //メイン関数
        static void Main(string[] args)
        {
            string s = ReadLine();

            switch (s)
            {
                case "Sunny":
                    WriteLine("Cloudy");
                    break;

                case "Cloudy":
                    WriteLine("Rainy");
                    break;

                case "Rainy":
                    WriteLine("Sunny");
                    break;
            }
        }




        #region 細々としたツール(関数)

        #region 標準入力
        //変数の入力
        static string scan() => ReadLine();
        static int scanInt() => int.Parse(ReadLine());

        //配列の入力
        static string[] MultiScan(char Split)
        {
            string[] N = ReadLine().Split(Split);
            return N;
        }
        static string[] MultiScan()
        {
            string[] N = ReadLine().Split(' ');
            return N;
        }

        static List<int> MultiScanInt(char Split)
        {
            string[] N = ReadLine().Split(Split);
            List<int> output = new List<int>();

            for (int i = 0; i < N.Length; i++)
            {
                output.Add(int.Parse(N[i]));
            }

            return output;
        }
        static List<int> MultiScanInt(char Split, int roop)
        { 
            string[] N = ReadLine().Split(Split);
            List<int> output = new List<int>();

            for (int i = 0; i < roop; i++)
            {
                output.Add(int.Parse(N[i]));
            }

            return output;
        }
        #endregion

        #region 数学関連
        public static int Gcd(int a, int b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }//最大公約数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }//最小公倍数
        public static int PlusOneSigma(int x, int loop)
        {
            int output = 0;
            for (int i = 0; i < loop; i++)
            {
                output = output + x + i;
            }
            return output;
        }//１づつ加算のシグマ
        #endregion

        #endregion
    }
}


Measured memory_bytes: 9044
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
//Cancel in interactive questions
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define got(container,num) get<num-1>(container)
using namespace std;
const int INF=LLONG_MAX/2;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;

main()
{
    IOS
    char h;
    cin>>h;
    if('a'<=h && h<='z')out('a')
    else out('A')
    return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
    ios::sync_with_stdio(false);
    string s;

    map<char, int> conv;
    conv['I'] =1;
    conv['V'] =5;
    conv['X'] =10;
    conv['L'] =50;
    conv['C'] =100;
    conv['D'] =500;
    conv['M'] =1000;

    while(cin >> s) {
        long ans = 0;
        for(int i=0; i<s.size()-1; i++) {
            if(conv[s[i]] < conv[s[i+1]])
                ans -= conv[s[i]];
            else
                ans += conv[s[i]];
        }
        ans += conv[s[s.size()-1]];
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1192
//***The night is the darkest just before the dawn***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
    ll k,s=0;
    cin>>k;

    for1(i,k)
    for1(j,k)
    for1(p,k)
        s+=__gcd(__gcd(i,j),p);
    cout<<s;
}

Measured memory_bytes: 3636
#include <iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;
int main()
{
    int n,a[MAX];
    cin>>n;
    for(int i =0; i<n; i++)
    {
        cin>>a[i];
    }
    int maxv = -2000000000,minv = a[0];
    for(int i=1;i<n;i++)
    {
        maxv = max(maxv,a[i]-minv);
        minv = min(minv,a[i]);
    }
    cout<<maxv<<endl;
    return 0;
}

Measured memory_bytes: 3872
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> p(n),q(n),tmp(n);
    rep(i,n){
        cin >> p[i];
    }
    rep(i,n){
        cin >> q[i];
    }
    reps(i,n) tmp[i-1] = i;

    int a,b;
    int j = 0;
    do{
        int flg1 = false,flg2 = false;
        rep(i,n){
            flg1 |= (tmp[i] != p[i]);
            flg2 |= (tmp[i] != q[i]);
        }
        if(!flg1) a = j;
        if(!flg2) b = j;
        ++j;
    }while(next_permutation(all(tmp)));

    cout << abs(b - a) << '\n';
    
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  set<int>S;
  for(int i=0;i<N;i++)
    S.insert(A.at(i));
  int ans=S.size();
  if(N%2==ans%2)
    cout<<ans<<endl;
  else
    cout<<ans-1<<endl;
return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>
#define MAX 100
#define LIM 1000000000

int n, A[MAX][MAX];

void dkstr();

int main(){

  int p,s,m,v;
  int i,j;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      A[i][j] = LIM;
    }
  }

  for(i = 0; i < n; i++){
    scanf("%d%d",&p,&s);
    for(j = 0; j < s; j++){
      scanf("%d%d",&m,&v);
      A[p][m] = v;
    }
  }

  dkstr();

  return 0;
}

void dkstr(){

  int s,small;
  int min[MAX],judge[MAX];
  int i,j;

  for(i = 0; i < n; i++){
    min[i] = LIM;
    judge[i] = 0;
  }

  min[0] = 0;
  judge[0] = 1;

  for(;;){

    small = LIM;
    s = -1;
    
    for(i = 0; i < n; i++){
      if(small > min[i] && judge[i] != 2){
	s = i;
	small = min[i];
      }
    }

    if( s == -1) break;
    judge[s] = 2;

    for( j = 0; j < n; j++){
      if(judge[j] != 2 && A[s][j] != LIM){
	if(min[j] > min[s] + A[s][j]){
	  min[j] = min[s] + A[s][j];
	  judge[j] = 1;
	}
      }
    }


  }

  for(i = 0; i < n; i++){
    printf("%d ",i);
    
    if(min[i] == LIM) printf("-1");
    else printf("%d",min[i]);
    printf("\n");

  }
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  ou(max(max(a+b,a-b),a*b));
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >>c ;
  bool flg = false;
  for(int i = 0; i < 100; i++) {
    int tmp = a*i;
    if(tmp%b == c) {
      flg = true;
      break;
    }
  }
  if(flg) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 3592
n,q=map(int,input().split())
s=input()
a=[0]*(n)
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    a[i+1]=a[i]+1
  else:
    a[i+1]=a[i]
for i in range(q):
  l,r=map(int,input().split())
  ans=a[r-1]-a[l-1]
  print(ans)

Measured memory_bytes: 6060
#include <functional>
#include <list>
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <deque>
#include <stack>
#include <cassert>
using namespace std;
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define ALL(x) (x).begin(),(x).end()
#define CASET2 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d:\n", case_n++) : 0), ___T-- > 0)
#define CASET1 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d: ", case_n++) : 0), ___T-- > 0)
#define CASET int ___T; scanf("%d ", &___T); while (___T-- > 0)
#define SZ(X) ((int)(X).size())
#define LEN(X) strlen(X)
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define PER1(i,a,b) for(int i=(a);i>=(b);i--)
#define REPL(i,x) for(int i=0;x[i];i++)
#define PER(i,n) for(int i=(n)-1;i>=0;i--)
#define RI1(x) scanf("%d",&x)
#define RI2(x,y) RI1(x), RI1(y)
#define RI3(x,y...) RI1(x), RI2(y)
#define RI4(x,y...) RI1(x), RI3(y)
#define RI5(x,y...) RI1(x), RI4(y)
#define RI6(x,y...) RI1(x), RI5(y)
#define GET_MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define RI(argv...) GET_MACRO(argv, RI6, RI5, RI4, RI3, RI2, RI1)(argv)
#define DRI(argv...) int argv;RI(argv)
#define WRI(argv...) while (RI(argv) != EOF)
#define DWRI(x...) int x; WRI(x)
#define RS(x) scanf("%s",x)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define X first
#define Y second
#define V(x) vector<x >

typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;
const int INF = 1000000000;

void print(int i) { printf("%d", i); }
void print(LL i);
template<class T> void PI(T i) { print(i); puts(""); }
template<class T> void PIS(T i) { print(i); printf(" "); }

template<class T>
void PV(T const &v, int N) {
    REP(i, N) {
        print(v[i]);
        printf("%c", i == N-1 ? '\n' : ' ');
    }
}

template<class T> void PV(T const &v) { PV(v, SZ(v)); }

template<class T, class S> bool has_bit(T mask, S i) { return (mask >> i) & 1; }
long long shift(int i) { return 1ll << i; }

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
int popcount(int x) { return __builtin_popcount(x); } 
int popcount(long long x) { return __builtin_popcountll(x); } 

#include <unordered_set>
#include <unordered_map>
#define EB emplace_back
#define RL(x) scanf("%lld", &(x))
#define PL(x) printf("%lld\n", x)
#define DRL(x) LL x; RL(x)

char s[400000];

int main() {
    DRI(N);
    RS(s);
    VI e(N+1);
    REP(i, N) {
        e[i+1] = e[i] + (s[i] == 'W');
    }
    int w = 0;
    int ans = INF;
    PER(i, N) {
        ans = min(ans, w + e[i]);
        w += (s[i] == 'E');
    }
    PI(ans);
    return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<utility>

using namespace std;
int n, f;//count
map<pair<string,string>,int> il;//itemlist
multimap<string,string>ans;


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

	for(int i=0; i<n; i++){
		int m;
		cin >> m;
		string s[15];
		for(int j=0; j < m; j++){
			cin >> s[j];
			for(int k=0; k < j; k++){
				string tmp[2] = {s[k], s[j]};
				sort(tmp, tmp+2);
				if(il.count(make_pair(tmp[0], tmp[1])) == 0) il.insert(make_pair(make_pair(tmp[0], tmp[1]),1));
				else {
					il[make_pair(tmp[0],tmp[1])]++;
				}
			}
		}
	}

	for(auto itr = il.begin(); itr != il.end(); itr++){
		if((*itr).second >= f){
			ans.insert((*itr).first);
		}
	}

	cout << ans.size() << endl;

	for(auto itr=ans.begin(); itr != ans.end(); itr++){
		cout << (*itr).first << ' ' << (*itr).second << endl;
	}

    return 0;
}



Measured memory_bytes: 3708
import java.util.*;
public class Main {

	public static long mod = 1000000007L ;

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

		int n = sc.nextInt();

		long g = 0L;	// goal
		long r = 0L;	// ruikei
		for ( int i=0; i<n; i++ ) {
			long a = sc.nextLong();

			long add1 = (a*r)%mod ;
			g = (g+add1)%mod ;
			r = (r+a)%mod ;
		}

		System.out.println(g);
	}
}

Measured memory_bytes: 59664
import java.util.Scanner;

public class Main {
	public static String input;
	public static int p;
	public static int len;
	public static boolean[] alpha = new boolean[11];
	public static void main(String[] args){
		doIt();
		//test();
	}
	
//	public static void test(){
//		int a = 0;
//		System.out.println(Character.getNumericValue('a'));
//		System.out.println(Character.getNumericValue('b'));
//	}
	

//	public static void print(int bit){
//		for(int i = 0; i < 11; i++){
//			int t = bit >> i;
//			t &= 1;
//			System.out.print(t);
//		}
//		System.out.println("");
//	}
	
	public static void doIt(){
		Scanner sc = new Scanner(System.in);
		input = sc.next();
		while(input.equals("#") == false){
			len = input.length();
			p = 0;
			boolean left;
			boolean right;
			boolean bOK = true;
			//int c = 0;
			int bit = 0;
			
			//2^(11) - 1までやる
			for(int i = 0; i < 0x800; i++){
				//print(bit);
				//c++;
				for(int j = 0; j < 11; j++){
					alpha[j] = bit2Bool(bit, j);
				}
				p = 0;
				left = getNext();
				p++;
				//System.out.println("right");
				right = getNext();
				
				if(left != right){
					//System.out.println("a = " + alpha[alpha2Int('a')] + ", b = " + alpha[alpha2Int('b')] + ", left = " + left + ", right = "  + right);;
					//System.out.println("bad");
					bOK = false;
				}
				bit++;
			}
			//System.out.println(c);
			
			if(bOK){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
			input = sc.next();
		}
	}
	
	//numのbit目のビットが立っていればtrue
	public static boolean bit2Bool(int num, int bit){
		int tmp = num >> bit;
		tmp &= 1;
		if(tmp == 1){
			return true;
		}
		else{
			return false;
		}
	}

	public static boolean getNext(){
		boolean bRet = false;
		char c = input.charAt(p);
		//System.out.println("getNext : p = " + p + ", c = " + c);
		switch(c){
		case 'T':
			p++;
			bRet = true;
			break;
		case 'F':
			bRet = false;
			p++;
			break;
		case 'a':
		case 'b':
		case 'c':
		case 'd':
		case 'e':
		case 'f':
		case 'g':
		case 'h':
		case 'i':
		case 'j':
		case 'k':
			bRet = alpha2Bool(c);
			p++;
			break;
		case '(':
			p++;
			boolean left = getNext();
			boolean right;
			c = input.charAt(p);
			if(c == '*'){
				p++;
				right = getNext();
				bRet = left & right;
			}
			else if(c == '+'){
				p++;
				right = getNext();
				bRet = left | right;
			}
			//case c = ->
			else{
				p += 2;
				right = getNext();
				bRet = Imp(left , right);
			}
			p++;
			break;

		case '-':
			p++;
			bRet = getNext();
			bRet = !bRet;
			break;
		}

		return bRet;
	}

	public static boolean alpha2Bool(char ch){
		int num = Character.getNumericValue(ch) - Character.getNumericValue('a');
		return alpha[num];
	}

	public static boolean Imp(boolean b1, boolean b2){
		if(b1 == true && b2 == false){
			return false;
		}
		else{
			return true;
		}
	}
}

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

int main(){
  int n;
  int c[500], s[500], f[500];
  cin >> n;
  for(int i = 0; i < n-1; i++) cin >> c[i] >> s[i] >> f[i];
  for(int i = 0; i < n; i++){
    int t = 0;
    for(int j = i; j < n-1; j++){
      if(t < s[j]) t = s[j];
      else if(t % f[j] != 0) t += f[j] - t % f[j];
      t += c[j];
    }
    cout << t << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
class Round
{
	public:
	double x,y,r;
	int c;
	Round(){}
	Round(double a,double b,double rr,int d)
	{
		x=a;y=b;r=rr;c=d;
	}
};

class Edge
{
	public:
	int to,cost;
	Edge(int t,int c)
	{
		to=t;cost=c;
	}
};

double dist(Round &r1,Round &r2)
{
	return sqrt((r1.x-r2.x)*(r1.x-r2.x)+(r1.y-r2.y)*(r1.y-r2.y));
}

bool contain(Round &r1,Round &r2)
{
	if(r1.r+r2.r>dist(r1,r2))
		return true;
	return false;
}
Round ban[30];
vector<Edge> g[30];
vector<Edge> rg[30];//逆辺グラフ
int dp[1<<24];//1のところだけ円盤が取り除かれているとき、さらに取り除くことのできる数

int access(int index,int n)
{
	//cerr<<index<<endl;
	if(dp[index]!=-1)
		return dp[index];
	dp[index]=0;
	bool f;
	vector<int> v;//上にある円盤
	for(int i=0;i<n;i++)
	{
		if(index&(1<<i))
			continue;
		f=true;
		for(int j=0;j<rg[i].size();j++)
		{
			if(!(index&(1<<rg[i][j].to)))
			{
				f=false;
				break;
			}
		}
		if(f)
			v.push_back(i);
	}
	for(int i=0;i<v.size();i++)
	{
		for(int j=i+1;j<v.size();j++)
		{
			if(ban[v[i]].c==ban[v[j]].c)
				dp[index]=max(dp[index],2+access(index^((1<<v[i])|(1<<v[j])),n));
		}
	}
	return dp[index];
}
int main()
{
	int n;
	int k;
	while(1)
	{
		cin>>n;
		if(n==0)
			break;
		k=0;
		for(int i=0;i<30;i++)
		{
			g[i].clear();
			rg[i].clear();
		}
		for(int i=0;i<n;i++)
		{
			double x,y,r;
			int c;
			cin>>x>>y>>r>>c;
			c--;
			ban[i]=Round(x,y,r,c);
			//自分より上について調べる
			for(int j=i-1;j>-1;j--)
			{
				if(contain(ban[i],ban[j]))
				{
					bool f=true;
					for(int k=0;k<g[j].size();k++)
					{
						for(int l=0;l<rg[i].size();l++)
						{
							if(g[j][k].to==rg[i][l].to)
							{
								f=false;
								break;
							}
						}
						if(!f)
							break;
					}
					if(f)
					{
						rg[i].push_back(Edge(j,1));
						g[j].push_back(Edge(i,1));
					}
				}
			}
		}
		//input end
		fill(dp,dp+(1<<24),-1);
		
		cout<<access(0,n)<<endl;
	}
	return 0;
}


Measured memory_bytes: 68760
#include <iostream>
using namespace std;
int main() {
	int long long a, b, tmp;
	cin >> a;
	cin >> b;

	int long long forres = a * b;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}
	if (a % b == 0) {
		cout << a;
		return 0;
	}
	int long long mod = a % b;

	while (mod != 0) {
		a = b;
		b = mod;
		mod = a % b;
	}
	cout << forres / b ;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve() {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int k=sc.nextInt();
		if(n>m) {
			int temp=n;
			n=m;
			m=temp;
		}
		
		for(int i=0;i<=m;i++) {
			for(int j=0;j<=n;j++) {
				if(k==n*i+(m-2*i)*j || k==m*j+(n-2*j)*i) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}

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

struct UnionFind {
    vector<int> par;
    UnionFind(int N) : par(N) {
        for (int i=0; i<N; i++) par[i]=i;
    }
    int root(int x) {
        if (par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x, int y) {
        int rx=root(x);
        int ry=root(y);
        if (rx==ry) return;
        par[rx]=ry;
    }
    bool same(int x,int y) {
        int rx=root(x);
        int ry=root(y);
        return rx==ry;
    }
};

int main() {
   int N,M;
   cin >> N >> M;
   int a[M],b[M];
   for (int i=0; i<M; i++) {
       int aa,bb;
       cin >> aa >> bb;
       a[i]=aa-1,b[i]=bb-1;
   }
   int count=0;
   for (int i=0; i<M; i++) {
       UnionFind tree(N);
       for (int j=0; j<M; j++) {
           if (i==j) continue;
           tree.unite(a[j],b[j]);
       }
       if (tree.same(a[i],b[i])) continue;
       count++;
   }
   cout << count << endl;
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

int main() {

  Dictionary d;

  int freq = 0;
  string longest = "";
  int longest_length = 0;

  for (string s; cin>>s, cin;) {
    d[s]++;
    freq = max(freq, d[s]);
    if (longest_length < s.size()) {
      longest = s;
      longest_length = s.size();
    }
  }

  string most_freq;
  for (auto&p : d) {
    if (freq == cdr(p)) {
      most_freq = car(p);
      break;
    }
  }

  cout << most_freq << ' ' << longest << endl;

  return 0;
}

Measured memory_bytes: 1196
//#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
*/
#define fr first
#define sc second
#define vec vector
#define pb push_back
#define pii pair<int, int>
#define forr(x,y,z) for(int x = (int)y ; x <= (int)z ; ++x)
#define forn(x,y) for(int x = 1; x <= (int)y; ++x)
#define all(x) (x).begin(),(x).end()
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> pll;
typedef unsigned int uint;
typedef complex<ll> point;
const int nmax = 3005;
const ll linf = 1e18;
const ll mod = 998244353;
const int inf = 1e9;





int n;

ll dp[nmax][nmax];

int main(){
	fast;
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	dp[a][b] = 1;
	for(ll i = a ; i <= c ; i++){
		for(ll j = b ; j <= d ; j++){
			if(i!= a || j != b){
				dp[i][j] = ((dp[i-1][j]*j%mod + dp[i][j-1]*i%mod - dp[i-1][j-1]*((i-1)*(j-1))%mod )+ mod)%mod;
			}
		}
	}
	cout << dp[c][d] << '\n';
}




Measured memory_bytes: 73924
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = I()
n = s // 3
dp = [[0] * (s+1) for _ in range(n+1)]
dp[0][0] = 1
dp[0] = list(accumulate(dp[0]))
for i in range(n):
    for j in range(3, s+1):
        dp[i+1][j] += dp[i][j-3]
        dp[i+1][j] %= mod
    dp[i+1] = list(accumulate(dp[i+1]))

ans = 0
for i in range(1, n+1):
    ans += dp[i][-1] - dp[i][-2]
    ans %= mod
print(ans)

Measured memory_bytes: 94444
using System;
using System.Collections.Generic;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Dictionary<string,int> judge = new Dictionary<string, int>() {{"AC", 0}, {"WA", 0}, {"TLE", 0}, {"RE", 0}};
            for(int i = 0; i < n; i++)
            {
                string key = Console.ReadLine();
                judge[key]++;
            }
            foreach(var value in judge)
            {
                System.Console.WriteLine("{0} x {1}",value.Key, value.Value);
            }
        }
    }
}


Measured memory_bytes: 30948
H, W = map(int, input().split())
A = [''] * H
for i in range(H):
  A[i] = input()

num_col_white = [0] * W
for i in range(H):
  for j in range(W):
    if A[i][j] == '.':
      num_col_white[j] += 1

for i in range(H):
  if A[i].count('.') == W:
    continue
  row = ''
  for j in range(W):
    if num_col_white[j] != H:
      row += A[i][j]
  print(row)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define A(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
void _read();
const int mod = 1e9+7;
template<typename T>
struct prefix_sum {
    vector<T> pref;
    int n;
    template<typename U>
    prefix_sum(vector<U> &vec) {

        n = vec.size();
        pref.resize(n);
        pref[0] = vec[0];
        for( int i = 1; i < n; i++) {
            pref[i] = pref[i-1] + vec[i];
            pref[i] %= mod;
        }
    }
    T sum ( int i ) {
        return pref[i];
    }
    T sum ( int i, int j ) {
        if ( i == 0 ) return pref[j];
        else return (pref[j] - pref[i-1] + mod) %mod;
    }
};
signed main () { _read(); 

      int n;
      cin >> n;
      vector<int> v(n);
      for( int &x : v ) cin >> x;
      prefix_sum<int> p(v);
      int sum = 0;
      for( int i = 0; i < n-1; i++ ) {
            (sum += (p.sum(i+1,n-1)*v[i])) %= mod;
      }
      cout << sum << '\n';
      return 0;
};

void _read() {
      ios_base :: sync_with_stdio(false);
      cin.tie(NULL);
      #ifdef LOCAL
      freopen("input.txt","r",stdin);
      #endif
}


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

int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  int n = s.size();

  vector<vector<int>> dp(n + 1, vector<int>(2, 1e9));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    int d = s[i] - '0';
    for (int j = 0; j < 2; j++) {
      dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + d + j);
      dp[i + 1][1] = min(dp[i + 1][1], dp[i][j] + (10 - d - j));
    }
  }
  cout << min(dp[n][0], dp[n][1] + 1) << endl;
}


Measured memory_bytes: 55940
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

string in[105];
int main() {
	int N, L;
	scanf("%d %d", &N, &L);
	for (int i = 0; i < N; i++) cin >> in[i];

	sort(in, in + N);
	for (int i = 0; i < N; i++) printf("%s", in[i].c_str());
	return !printf("\n");
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
namespace AOJ {
  public class AOJ {
    public static void Main(string[] args) {
      IntPair[] data = new IntPair[10000];
      int n;
      for(n = 0;; ++n) {
        int[] m = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        if(m[0] == 0 && m[1] == 0) break;
        data[n] = m[0] < m[1] ? new IntPair(m[0], m[1]) : new IntPair(m[1], m[0]); 
      }
      for(int i = 0; i < n; ++i) {
        Console.WriteLine("{0} {1}", data[i].Item1, data[i].Item2);
      }
    }

    internal struct IntPair {
      internal int Item1;
      internal int Item2;
      internal IntPair(int x, int y) { Item1 = x; Item2 = y; }
    }
  }
}

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

int main()
{
	int i,x,count;
	int hairetu[10000];        //配列宣言           
	x = 0;
	count = 0;

	while (count < 10000) //最大1万回
	{        
		cin >> x;
		if ((1 <= x) && (x <= 10000)) 
		{
			hairetu[count] = x  ;  //入力した値を配列へ
			count++;
		}
		else
		{

		}
			if (x == 0) 
			{
				break;
			}
		
	}
		for (i = 0; i < count; i++) 
		{
			cout << "Case " << i + 1 << ": " << hairetu[i] << endl;
		}



	return 0;


}


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

using namespace std;

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

#define SZ(x) ((int)(x).size())
#define all(x) begin(x),end(x)

#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP (i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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 (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector <vector<int>>;
using vvll = vector <vector<ll>>;

#define inf(T) (numeric_limits<T>::max() / 2)
const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    for (;;) {
        int n, m;
        cin >> n >> m;
        if (n == 0) break;

        vi a(n);
        REP(i, n) cin >> a[i];

        int ans = -1;

        REP(i, n) FOR(j, i+1, n) {
            if (a[i] + a[j] <= m) chmax(ans, a[i] + a[j]);
        }

        if (ans == -1) cout << "NONE" << endl;
        else cout << ans << endl;
    }


    return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    cout << max(0ll,b+c-a);
}

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

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

  long long ret = 1;
  if(a+2 < b && k >= a+1){
    ret = b;
    k -= a+1;
    ret += (long long)(b - a)*(k/2);
    k = k%2;
  }
  cout << ret + k << endl;
}


Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  ll n,k;
  cin >> n >> k;
  ll h[n];
  rep(i,n) cin >> h[i];
  sort(h,h+n,greater<ll>());
  if(k >= n){
    printf("0\n");
    return 0;
  }
  rep(i,k){
    h[i] = 0;
  }
  ll cnt = 0;
  rep(i,n){
    cnt += h[i];
  }
  printf("%lld\n", cnt);
  return 0;
}


Measured memory_bytes: 1792
import math
while True:
    n = int(input())
    if n == 0: break
    point = [float(x) for x in input().split()]
    sum = 0
    for i in range(n):
        sum += point[i]
    ave = sum / n
    var = 0
    for i in range(n):
        var += (point[i] - ave)**2
    var /= n
    print(math.sqrt(var))


Measured memory_bytes: 5780
T = list(input())
ex=None
for i in range(len(T)):
  if T[i] == "?":
    if ex == "P" or ex == None:
      T[i] = "D"
    else:
      if len(T)-1 == i:
        T[i] = "D"
      elif T[i+1] == "D" or T[i+1] == "?":
        T[i] = "P"
      else:
        T[i] = "D"
  ex = T[i]
print("".join(T))

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

int main(){
    long long N;
    cin >> N;
    queue<long long> q;
    q.push(0);
    int count = 0;
    while( !q.empty() ){
        long long t = q.front(); q.pop();
        if ( t > N ) continue;
        long long t_tmp = t;
        bool b3 = false;
        bool b5 = false;
        bool b7 = false;
        while( t_tmp > 0 ){
            switch ( t_tmp % 10 )
            {
            case 3:
                b3 = true;
                break;
            case 5:
                b5 = true;
                break;
            case 7:
                b7 = true;
                break;
            default:
                break;
            }
            t_tmp = t_tmp / 10;
        }
        if ( b3 && b5 && b7 ) ++count;
        q.push( 10*t + 3 );
        q.push( 10*t + 5 ); 
        q.push( 10*t + 7 );
    }
    cout << count;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

int main(){
    int n,K; cin >> n >> K;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int ans=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(i+j>K||i+j>n)continue;
            vector<int> v;
            for(int l=0;l<i;l++){
                v.push_back(a[l]);
            }
            for(int r=0;r<j;r++){
                v.push_back(a[n-1-r]);
            }
            sort(v.begin(),v.end());
            int sum=0;
            for(int k=0;k<v.size();k++){
                sum+=v[k];
            }
            ans=max(ans,sum);
            for(int k=1;k<=v.size();k++){
                if(i+j+k>K)continue;
                sum-=v[k-1];
                ans=max(ans,sum);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;

long long gcd(long long a,long long b)
{
    if(a==0) return b;
    else return gcd(b%a,a);
}

int main()
{
	long long a,b,c,d,e;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	a--;
	e=c*d/gcd(c,d);
	printf("%lld",b-a-b/c+a/c-b/d+a/d+b/e-a/e);
	return 0;
}

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

int main()
{
	//string cat;
	//cin >> cat;
	//for (int i = 0; i < 3; i++)
	//{
	//	if (cat[i] == '7')
	//	{
	//		cout << "Yes";
	//		exit(0);
	//	}
	//}
	//cout << "No";
	
	long long num;
	long long duck = 0;
	cin >> num;
	for (int i = 1; i <= num; i++)
	{
		if (i % 3 == 0)continue;
		else if (i % 5 == 0)continue;
		duck += i;
	}
	cout << duck;
	return 0;
}



Measured memory_bytes: 3624
#include<iostream>
#include<string>
using namespace std;
int main() {
	string S;
	cin >> S;
	if (S == "Sunny") {
		cout << "Cloudy" << endl;
	}
	else if (S == "Cloudy") {
		cout << "Rainy" << endl;
	}else cout<<"Sunny"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main(){
	string s[12];
	while (cin >> s[0]){
		for (int i = 1; i < 12; i++)
		{
			cin >> s[i];
		}
		stack<int>s1, s2;
		int shima = 0;
		for (int y = 0; y < 12; y++)
		{
			for (int x = 0; x < 12; x++)
			{
				if (s[x][y] == '1')
				{
					//cout << x << " " << y << endl;
					shima++;
					s1.push(x);
					s2.push(y);
					while (!s1.empty())
					{
						int X = s1.top();
						int Y = s2.top();
						s1.pop();
						s2.pop();
						//X+1 Y
						//X-1 Y
						//X Y+1
						//X Y-1

						if (X + 1 < 12 && s[X + 1][Y] == '1')
						{
							s1.push(X + 1);
							s2.push(Y);
						}
						if (0 <= X - 1 && s[X - 1][Y] == '1')
						{
							s1.push(X - 1);
							s2.push(Y);
						}
						if (Y + 1 < 12 && s[X][Y + 1] == '1')
						{
							s1.push(X);
							s2.push(Y + 1);
						}
						if (0 <= Y - 1 && s[X][Y - 1] == '1')
						{
							s1.push(X);
							s2.push(Y - 1);
						}
						s[X][Y] = 0;
					}
				}
			}
		}
		cout << shima << endl;
	}
	return 0;
}


Measured memory_bytes: 3168
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	cnt := 0
	for i := a; i <= b; i++ {
		is := strconv.Itoa(i)
		
		if is[0] == is[4] && is[1] == is[3] {
			cnt++
		}
	}

	fmt.Println(cnt)
}

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

using namespace std;

char s[300010];
int n;

int main() {
  scanf("%d %s", &n, s);
  int ce = 0, cw = 0;
  int ans = n + 100;
  for (int i = 0; i < n; i++) {
    ce += (s[i] == 'E');
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) {
      cw += (s[i - 1] == 'W');
    }
    ce -= (s[i] == 'E');
    ans = min(ans, ce + cw);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main {
	HashMap<Character, Integer> change;
	
	//0308 start
	//0352 cording end
	//0353 WA
	private void doit(){
		Scanner sc = new Scanner(System.in);
		initchangeNum();
		while(true){
			String trump = sc.next();
			if(trump.equals("#")){
				break;
			}
			int n = 4;
			String [][] deck = new String[n][13];
			for(int i = 0; i < 4; i++){
				for(int j = 0; j < 13; j++){
					deck[i][j] = sc.next();
				}
			}
			
			int nspoint = 0, ewpoint = 0, leaderInd = 0;
			for(int i = 0; i < 13;i++){
				int nextind = leaderInd;
				String nextString = deck[leaderInd][i];
				char nextmark = nextString.charAt(1);
				int nextpower = change.get(nextString.charAt(0));
				for(int j = leaderInd + 1; j < leaderInd + 4; j++){
					int jind = j % 4;
					String now = deck[jind][i];
					int nowpower= change.get(now.charAt(0));
					char nowmark = now.charAt(1);
					if(nextmark == nowmark){
						if(nextpower < nowpower){
							nextind = jind;
							nextString = deck[jind][i];
							nextmark = nowmark;
							nextpower = nowpower;
						}
					}
					else{
						//mark
						if(trump.charAt(0) == nowmark){
							nextind = jind;
							nextString = deck[jind][i];
							nextmark = nowmark;
							nextpower = nowpower;
						}
					}
				}
				if(nextind % 2 == 0){
					nspoint++;
				}
				else{
					ewpoint++;
				}
				leaderInd = nextind;
			}
			if(nspoint > ewpoint){
				System.out.println("NS " + (nspoint - 6));
			}
			else{
				System.out.println("EW " + (ewpoint - 6));
			}
		}
	}
	private void initchangeNum() {
		change = new HashMap<Character, Integer>();
		for(int i = 0; i < 10; i++){
			change.put((char)('0' + i), i);
		}
		change.put('T', 10);
		change.put('J', 11);
		change.put('Q', 12);
		change.put('K', 13);
		change.put('A', 14);
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<double, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n + 1);
	rep(i, n + 1) cin >> a[i];
	if (n != 0 && a[0] != 0) {
		cout << -1 << endl;
		return 0;
	}
	if (n == 0 && a[0] != 1) {
		cout << -1 << endl;
		return 0;
	}
	vector<ll> mx(n + 1);
	ll now = 0;
	for (int i = n; i >= 0; --i) {
		now += a[i];
		mx[i] += now;
	}
	ll ans = 1;
	now = 1;
	for (int i = 1; i <= n; ++i) {
		now *= 2;
		if (now < a[i]) {
			cout << -1 << endl;
			return 0;
		}
		ans += min(mx[i], now);
		now = min(now - a[i], mx[i]);
	}
	cout << ans << endl;
 	return 0;
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 500010;
const int INF = LLONG_MAX/4;

int n,q;
map <int, int> mp;
int A[maxn];
int32_t main() {
	FAST
	cin >> n;
	for (int i =0;i<n;i++) cin >> A[i];
	
	int sum = 0;
	for (int i =0;i<n;i++) {
		mp[A[i]] += 1;
		sum += A[i];
	}
	
	cin >> q;
	for (int i =0;i<q;i++) {
		int oldv, newv; cin >> oldv >> newv;
		int co = mp[oldv];
		
		sum += (newv - oldv) * co;
		mp[oldv] = 0;
		mp[newv] += co;
		cout << sum << "\n";
	}
	
}









Measured memory_bytes: 10212