akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define mii map<int,int>
#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main() {
	io;
	int n;
  	cin>>n;
  	int b[n-1];
  	for(int i=0;i<n-1;i++) cin>>b[i];
  	ll int an=0;
  	int ans[n];
  	ans[0]=b[0];
  ans[1]=b[0];
  for(int i=1;i<n-1;i++){
   if(b[i]<=ans[i]){
   	ans[i]=b[i];
   }
    ans[i+1]=b[i];
  }
  for(int i=0;i<n;i++) an+=ans[i];
  cout<<an;
	return 0;
}

Measured memory_bytes: 256
import sys
from math import log10, floor, ceil
from itertools import combinations, product
n = int(input())
n_start = int(str(n)[0])
n_last = int(str(n)[-1])
n_keta = floor(log10(n)) + 1
dic = {i:0 for i in product(range(10), repeat=2)}
#memo_ls[i][j][k] : i番目まででjスタートでflgがkの時の通り数
memo_ls = [[[0 for k in range(2)] for j in range(10)] for i in range(n_keta)]
if n_keta == 1:
    print(n_start)
else:
    for i in range(n_start + 1):
        if i < n_start:
            memo_ls[0][i][1] = 1
        else:
            memo_ls[0][i][0] = 1
    for i, x in enumerate(str(n)[1:-1], 1):
        x = int(x)
        for j in range(10):
            for k in range(10):
                if j < x:
                    memo_ls[i][k][1] += memo_ls[i-1][k][0] + memo_ls[i-1][k][1]
                elif j == x:
                    memo_ls[i][k][0] = memo_ls[i-1][k][0]
                    memo_ls[i][k][1] += memo_ls[i-1][k][1]
                else:
                    memo_ls[i][k][1] += memo_ls[i-1][k][1]
            memo_ls[i][j][1] += 1
    score = 0
    for i in range(10):
        for j in range(10):
            if j <= n_last:
                score = sum(memo_ls[-2][i])
            else:
                score = memo_ls[-2][i][1]
            dic[(i, j)] = score
    for i in range(10):
        dic[(i, i)] += 1
        dic[(0, i)] = 0
    ans = 0
    for i in product(range(10), repeat=2):
        ans += dic[i] * dic[(i[1], i[0])]
    print(ans)

Measured memory_bytes: 38384
N=int(input())
dp=[0]*4
for i in range(N):
  S=input()
  if S=='AC':
    dp[0]+=1
  elif S=='WA':
    dp[1]+=1
  elif S=='TLE':
    dp[2]+=1
  else:
    dp[3]+=1
for j in range(4):
  if j==0:
    print('AC x '+str(dp[j]))
  elif j==1:
    print('WA x '+str(dp[j]))
  elif j==2:
    print('TLE x '+str(dp[j]))
  else:
    print('RE x '+str(dp[j]))

Measured memory_bytes: 9228
#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y);
#define sz(x) (int)(x.size())
#define nax 100010
#define inf 1001000100
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pc pair<char ,int>
#define pi pair<int ,int>
#define pii pair <int,pi>
#define ull unsigned long long int
using namespace std;
int arr[nax];
int siz[nax];
vector< ll > ans;
vector< pi > v;

int root(int x)
{
	while(arr[x] != x)
	{
		 x = arr[x];
		 arr[x] = arr[arr[x]];
	}
	return x;
}

ll unite(int a, int b)
{
	a = root(a);
	b = root(b);
	ll ret = siz[a] * 1ll * siz[b];
	if(siz[a] > siz[b])
	{
		arr[b] = a;
		siz[a] += siz[b];
	}
	else
	{
		arr[a] = b;
		siz[b] += siz[a];
	}
	return ret;
}


int main() {
 
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,m;
    sd2(n,m);
    int a,b;
    for(int i = 1; i <= n; i++)
    {
    	siz[i] = 1;
    	arr[i] = i;
    }

    for(int i = 0 ; i < m; i++)
    {
    	sd2(a,b);
    	v.pb(mp(a,b));
    }

    ll fans = n * 1ll * (n - 1);
    fans /= 2;
    reverse(v.begin(), v.end());
    for(int i = 0; i < m; i++)
    {
    	a = v[i].F;
    	b = v[i].S;
    	ans.push_back(fans);
    	if(root(a) != root(b))
    		fans -= unite(a, b);
    }
    reverse(ans.begin(), ans.end());

    for (int i = 0; i < m; ++i)
    	printf("%lld\n", ans[i]);

    return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define f(i,n) for(ll i=0;i<n;i++)
    #define fz for(ll j=i+1;j<n;j++)
    #define f2(i,n) for(ll i=1;i<=n;i++)
    #define endl "\n"
    #define vll vector <ll>
    #define mod 1000000009
    #define pb push_back
    #define inf 1e13+5

    ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
    ll lcm(ll a, ll b){return a*b/gcd(a, b);}
    ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod; b/=2;a=a*a%mod;}return ans;}
    ll inverse(ll a, ll p){return fexp(a, p-2);}

    
    void solve(){
       ll n;cin>>n;
       ll mat[100005][3]={0};
       f(i,n){
           f(j,3)cin>>mat[i][j];
       }
       ll dp[100005][3]={0};
       f(i,3){
           dp[0][i]=mat[0][i];
       }
       f2(i,n-1){
           dp[i][0]=max( dp[i-1][1]+mat[i][0], dp[i-1][2]+mat[i][0]  );
           dp[i][1]=max( dp[i-1][0]+mat[i][1], dp[i-1][2]+mat[i][1]  );
           dp[i][2]=max( dp[i-1][1]+mat[i][2], dp[i-1][0]+mat[i][2]  );
       }
       ll a=dp[n-1][0],b=dp[n-1][1],c=dp[n-1][2];
       cout<<max(max(a,b),c)<<endl;


    }


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

       
        ll t;
        t=1;
        // cin>>t;
        while(t--){
            solve();
        }

       
        
        return 0;
    }

Measured memory_bytes: 4992
#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[i];
  long long ans = 1000;
  for(int i = 0; i< n-1; i++){
   if(a[i] < a[i+1]){
    ans += (a[i+1]-a[i]) * (ans/a[i]); 
   }
  }
  cout<<ans<<endl;
 return 0; 
}

Measured memory_bytes: 3620
/*
Kaushal Jalan
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop int t;cin>>t;while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod 1000000007
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
	return (a<b)?a:b;
}
int max(int a,int b){
	return (a>b)?a:b;
}
int fp(int a,int b){
	if(b==0) return 1;
	int x=fp(a,b/2);
	x=(x*x)%mod;
	if(b&1) x=(x*a)%mod;
	return x;
}
 
signed main()
{
    crap;
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=1e5+5;
ll mod=1e9+7;
#define pb push_back
#define se second
#define fi first
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int check(string s1){
    int count1=0;
     for(int i=0;i+1<s1.length();i++){
        if(s1[i]==s1[i+1])
            {count1++;i++;}
        else;
           // cout<<count1<<" ";
    }
    return count1;
}
int equal(string s){
    int i;
    for(i=0;i+1<s.length();i++)
    if(s[i]==s[i+1])continue;
    else break;
    if(i+1==s.length())
    return 1;
    return 0;
}
int main(){
    boost;
    string s;
    long long k;
    cin>>s;
    cin>>k;
    if(s.length()==1)
    cout<<k/2;
    else{
   string s2=s;
   s2+=s;
   int t1=check(s);
   int t2=check(s2);
   //cout<<t1<<t2<<endl;
   if(equal(s))
   cout<<k*(s.length())/2;
   else{
   long long ans=t1*k+(t2-2*t1)*(k-1);
   cout<<ans<<endl;}}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
typedef unsigned long long int ull;
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
    int n,k;
    string s;
    cin>>k>>s;
    n=SZ(s);
    if(n<=k){
        cout<<s;
        return 0;
    }
    cout<<s.substr(0,k)+"...";
    

    
	

   return 0;
}


Measured memory_bytes: 3668
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    data_set;
#define rep(i,l,r)   for(int i=(l);i<(r);i++)
#define deb(x)     cout << (#x) << " = " << (x) << endl
#define here cout << " Hey!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld EPS = 1e-12;
const ld PI = 3.141592653589793116;

int32_t main()
{
	SYNC
	int n; cin >> n;
	vector<char> ans;
	while(n)
	{
		int cur = n%26;
		if(cur == 0)
			ans.pb('z');
		else
			ans.pb((char)('a'+cur-1));
		n--;
		n /= 26;
	}
	reverse(all(ans));
	for(auto it : ans)	cout << it;
	return 0;
}

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

namespace ABC169
{
    class C
    {
        static void Main(string[] args)
        {
            // var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            // var CA = Enumerable.Repeat(0, (int)N).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            //var N = long.Parse(Console.ReadLine());
            var AB = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
            Console.WriteLine((decimal)Math.Floor(AB[0] * AB[1]));
        }
    }
}


Measured memory_bytes: 28316
W, H, N = map(int, input().split())
xya = [list(map(int, input().split())) for i in range(N)]
X=Y=0
for i in range(N):
    if xya[i][2] == 1:
        X = max(X,xya[i][0])
    if xya[i][2] == 2:
        W = min(W,xya[i][0])
    if xya[i][2] == 3:
        Y = max(Y,xya[i][1])
    if xya[i][2] == 4:
        H = min(H,xya[i][1])
print(max(W-X,0)*max(H-Y,0))

Measured memory_bytes: 9108
use std::io;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();

    stdin.read_line(&mut buf).unwrap();

    let rgb: Vec<usize> = buf.split_whitespace().map(|n| n.parse().unwrap()).collect();

    if (rgb[0] * 100 + rgb[1] * 10 + rgb[2]) % 4 == 0 {
        println!("YES");
    } else {
        println!("NO");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n;
  cin>>n;
  string s,t;
  cin>>s;
  cin>>t;
  string temps,tempt;
  int ans=2*n;
  REP(i,n){
    temps = s.substr(n-1-i,i+1);
    tempt = t.substr(0,i+1);
    if(temps==tempt){
      ans = 2*n-(i+1);
    }else{
      continue;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
li = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")

n = int(input())
s = list(input())

for i in range(len(s)):
    for j in range(len(li)):
        if s[i] == li[j]:
            memo = j
            break
    s[i] = li[(j+n)%26]

for i in range(len(s)):
    print(s[i],end="")
print()

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

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)
#define sz(x) int32_t(x.size())

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
// --------------------------------------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9 + 7;
const int INF = 2e18;
const ld EPS = 1e-9;
const int NN = 1e5 + 2;

vvi g(NN);
void solve() {
      int i = 0, j = 0, k = 0, n = 0, m = 0; 
      cin >> n >> m;
      fr(j, 0, m) {
            int a,b;
            cin>>a>>b;
            a--; b--;
            g[a].pb(b);
            g[b].pb(a);
      }

      vi par(n, -1);
      vector<bool> vis(n, 0);
      vis[0] = 1;
      queue<int> q;
      q.push(0);
      while(!q.empty()) {
            int x = q.front();
            q.pop();

            for(int adj : g[x]) {
                  if(!vis[adj]) {
                        par[adj] = x;
                        vis[adj] = 1;
                        q.push(adj);
                  }
            }
      }
      cout << "Yes\n";
      fr(i, 1, n) {
            assert(par[i] != -1);
            cout << par[i]+1 << el;
      }
}

int32_t main() {
      ios::sync_with_stdio(false); cin.tie(0); 
      int T = 1; 
      // cin >> T;
      for(int tc = 1; tc <= T; tc++) {
            solve();
       }
      return 0;
}

Measured memory_bytes: 12996
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

string s;
bool ok = true;
int main() {
	cin >> s;
	REP(i, s.size()) {
		if (i % 2 == 0 and s[i] == 'L')ok = false;
		if (i % 2 == 1 and s[i] == 'R')ok = false;
	}
	cout << (ok ? "Yes" : "No") << endl;
}




Measured memory_bytes: 384
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const ll mod=1e9+7;
using namespace std;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	int s,w;
	cin>>s>>w;
	if(w>=s)rc("unsafe");
	cout<<"safe"<<endl;
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A, B; cin >> A >> B; 
    cout << max({A + B, A - B, A * B}) << endl;

    return 0;
}


Measured memory_bytes: 256
let pow x n m =
  let rec doit x n acc =
    if n = 0 then acc
    else if n mod 2 = 0 then doit (x * x mod m) (n / 2) acc
    else doit (x * x mod m) (n / 2) (acc * x mod m) in
  doit x n 1

let prime_p n =
  if n == 2 then true
  else if n < 2 || n mod 2 = 0 then false
  else if pow 2 (n - 1) n = 1 then true
  else false

let () =
  let n = read_int () in
  let rec doit i acc =
    if i = n then acc
    else doit (i + 1) (acc + (if read_int () |> prime_p then 1 else 0)) in
  doit 0 0 |> Printf.printf "%d\n"

Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		int cnt = (int)((C + 0.5) / A);
		
		System.out.println(cnt * B);
	}

}


Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

// 最大公約数を求める関数
// The Greatest Common Divisor 
// 計算量は log(max(a,b))
ll gcd(int a, int b) { // a >= b;
	if (b > a) swap(a, b);
	if (b == 0) return a;
	else return gcd(b, a % b);
}

// 最小公倍数を求める関数
// The Least Common Multiple
ll lcm(int a, int b) {
	return a / gcd(a, b) * b; // 桁溢れに注意
							  // この順番で計算するべし
}


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

	ll A, B; cin >> A >> B;
	cout << lcm(A, B) << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int N; int M;
	while (~scanf("%d%d", &N, &M)) {
		vector<int> xs(M);
		vector<int> ys(M);
		for (int i = 0; i < M; ++ i)
			scanf("%d%d", &xs[i], &ys[i]), -- xs[i], -- ys[i];
		vector<vector<bool>> table(N);
		rep(u, N) {
			vector<bool> v(N);
			v[u] = true;
			for (int i = M - 1; i >= 0; -- i) {
				int x = xs[i], y = ys[i];
				if (v[x] && v[y]) {
					v.assign(N, true);
					break;
				} else if (v[x] && !v[y]) {
					v[y] = true;
				} else if (!v[x] && v[y]) {
					v[x] = true;
				}
			}
			table[u] = v;
		}
		int ans = 0;
		rep(u, N) reu(v, u + 1, N)
			ans += !inner_product(table[u].begin(), table[u].end(), table[v].begin(), false, logical_or<bool>(), logical_and<bool>());
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<cmath>

using namespace std;
typedef long long LL;
const int N=100050;
int a[N],n,q;

int main(){
	
	int i,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=1;i<n;i++){
		if(a[i]==i){
			swap(a[i],a[i+1]);
			q++;
		}
	}
	if(a[n]==n)q++;
	cout<<q;
	

	return 0;
}


Measured memory_bytes: 640
L = input()
n = len(L)
mod = 10**9+7
pow3 = [1]
for i in range(1,n):
    x = (3*pow3[i-1])%mod
    pow3.append(x)
ans = 0
for i in range(1,n+1):
    if L[-i] == '1':
        if i == 1:
            ans = 3
        else:
            ans = ans*2 % mod
            ans = (ans + pow3[i-1])%mod
    else:
        if i == 1:
            ans = 1
print(ans)

Measured memory_bytes: 7156
n = int(input())
lis = list(map(int,input().split()))
AngeKatrina = 0
LizeHelesta = 0
for i,InuiToko in list(enumerate(lis)):
  if InuiToko >= 0:
    if InuiToko >= AngeKatrina:
      AngeKatrina = InuiToko
      AngeSoko = i+1
  else:
    if -InuiToko >= LizeHelesta:
      LizeHelesta = -InuiToko
      LizeHiyoko = i+1
print(2*n-1)
if AngeKatrina >= LizeHelesta:
  for i in range(1,n+1):
    print(AngeSoko,i)
  for i in range(1,n):
    print(i,i+1)
else:
  for i in range(1,n+1):
    print(LizeHiyoko,i)
  for i in range(n,1,-1):
    print(i,i-1)

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

using namespace std;

#define lli unsigned long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){

	lli n,k;
	string s;
	cin>>n>>k>>s;

	s[k-1] = s[k-1] -'A' + 'a';

	cout<<s<<endl;

	return 0;
}

Measured memory_bytes: 256
import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n = I()
    a_list = LI()

    c = Counter(a_list)
    for i in range(1, n + 1):
        print(c[i])

    pass


if __name__ == "__main__":
    main()


Measured memory_bytes: 116664
// 25
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j;
  int key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);

  trace(A, n);

  for ( i = 2; i <= n; i++){
    key = A[i];
    j = i-1;
    while ((j >= 0)&&(A[j] >= key )){
      A[j+1] = A[j];
      j--;
    }
    A[j+1]=key;

    trace(A ,n);

  }

  return 0;
}



Measured memory_bytes: 2140
#include<stdio.h>

#define MAXLENGTH 100

int main(void)
{
	int i, j, n, m, l, k;
	long int a[MAXLENGTH][MAXLENGTH],b[MAXLENGTH][MAXLENGTH];
	long int c[MAXLENGTH][MAXLENGTH];
	scanf("%d %d %d", &n, &m, &l);

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			scanf("%ld", &a[i][j]);
		}
	}
		
	for (j = 0; j < m; j++)
	{
		for (k = 0; k < l; k++)
		{
			scanf("%ld",&b[j][k]);
		}
	}
		
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < l; j++)
		{
			c[i][j] = 0;
		}
	}

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < l; j++)
		{
			for (k = 0; k < m; k++)
			{
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < l-1; j++)
		{
			printf("%ld ", c[i][j]);
		}
		printf("%ld\n",c[i][l-1]);
	}
		
}


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

signed main() {
  int N;
  cin >> N;
  
  vector<int> L(N);
  vector<int> total(3010, 0);
  for( int i = 0; i < N; i++ ){
    cin >> L.at(i);
    total.at(L.at(i))++;
  }
  
  for( int i = 1; i <= 3000; i++ ){
    total.at(i) += total.at(i-1);
  }
  
  int ans = 0;
  int A, B;
  sort(L.begin(), L.end());
  for( int i = 0; i < N; i++ ){
    A = L.at(i);
    for( int j = i+1; j < N; j++ ){
      B = L.at(j);
      ans += total.at(A+B-1) - total.at(B-A);
      if( B-A <A && A <= A+B-1 ) ans--;
      if( B-A < B && B <= A+B-1 ) ans--;
    }
  }
  cout << ans / 3 << endl;
    
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define for(index,first,num) for(int index=(int)first;index<(int)num;index++)
using namespace std ;
typedef long long ll;
 
int main(){
    int N,D;cin>>N>>D;

    int count = N/(2*D+1);
    if(N%(2*D+1)==0)cout << count;
    else cout << count+1;
    
      
}

Measured memory_bytes: 3624
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();  
        int N = r.i();
        int root = (int)Math.sqrt(N);
        println(root*root <= N ? root*root : (root-1)*(root-1));
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 23252
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int ans = Math.Max(inpt[0] + inpt[1], Math.Max(inpt[0] - inpt[1], inpt[0] * inpt[1]));
        Console.WriteLine(ans);




    }


	public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



4 -2


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    ll N, X, M;
    cin >> N >> X >> M;
    map<ll, bool> used; used[X] = true;
    vector<ll> loop = {X};
    ll before = X;
    while (true) {
        before = before * before % M;
        if (used[before]) break;
        loop.push_back(before);
        used[before] = true;
    }

    int start_i = 0;
    REP(i, loop.size()) {
        if (loop[i] == before) {
            start_i = i;
            break;
        }
    }

    ll ans = 0;
    if (N <= loop.size()) {
        REP(i, N) ans += loop[i];
        cout << ans << endl;
        return 0;
    }

    REP(i, start_i) ans += loop[i];
    N -= start_i;
    int loop_size = loop.size() - start_i;
    ll sum = 0;
    FOR(i, start_i, loop.size()) {
        sum += loop[i];
    }
    ans += sum * (N / loop_size);
    REP(i, N % loop_size) {
        ans += loop[start_i + i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6684
import numpy as np

n, m = map(int, input().split())

tastes = np.zeros((n, m), dtype=np.int8)
for i in range(n):
    ka = list(map(int, input().split()))
    for j in range(ka[0]):
        # print(i, ka[j + 1] - 1)
        tastes[i][ka[j + 1] - 1] = 1
    
    # for t in tastes:
    #     print(t)
    # print("---")

# tastes = np.array(tastes)
# print(tastes)

score = np.sum(np.sum(tastes == 1, axis=0) == n)
print(score)

Measured memory_bytes: 12484
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


N = I()
ans = 0
for i in range(1, N+1):
    temp = str(i)
    if len(temp) % 2 == 1:
        ans += 1
print(ans)


Measured memory_bytes: 38896
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
a = [0 for i in range(m-1)]
for i in range(m-1):
    a[i] = x[i+1]-x[i]
a.sort()
count = 0
for i in range(m-n):
    count+=a[i]
print(count)

Measured memory_bytes: 13964
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct item { // value and weight for each item
  int value; 
  int weight;
};


int grid[100][100001] = {{0}}; // table for DP


int main()
{
  int N, W; // no. of inputs, max weight
  cin >> N >> W;
  
  vector<item> items; // array to store item properties

  for (int i = 0; i < N; ++i) {
    int value, weight;
    cin >> value >> weight;
    item cur_item = {value, weight};
    items.push_back(cur_item);
    grid[i][0] = 0; // initialize first column
  }

  for (int i = 0; i <= W; ++i) {
    grid[0][i] = (items[0].weight <= i)?items[0].value:0; //initialize first row
  }

  for(int i = 1; i < N; ++i) {
    for (int j = 1; j <= W; ++j) {
      if (items[i].weight <= j) {
	grid[i][j] = max(items[i].value + grid[i-1][j-items[i].weight], grid[i-1][j]);
      } else {
	grid[i][j] = grid[i-1][j];
      }
    }
  }


    cout << grid[N-1][W] << endl;
  
  return 0;
}

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

using namespace std;
#define int long long
const int INF = 200000000007;


 
signed main(){
    int n;
    cin>>n;
  
    vector<int> ko[n];
   int a[n-1],b[n-1];

   for(int i=0;i<n-1;i++){
       cin>>a[i]>>b[i];
    
         ko[min(a[i],b[i])-1].push_back(max(a[i],b[i])-1);
         a[i]--;
         b[i]--;

   }
    int c[n],ans[n],p=0,csum=0;
    for(int i=0;i<n;i++){
        cin>>c[i];
        csum+=c[i];
    }
    sort(c,c+n);
    int cou=n-1;
    for(int i=0;i<n;i++)ans[i]=-1;
    ans[a[0]]=c[cou];
    cou--;
    ans[b[0]]=c[cou];
    cou--;
    while(cou!=-1){
        for(int i=0;i<n-1;i++){
            if((ans[a[i]]==-1)&&(ans[b[i]]!=-1)){
   
                ans[a[i]]=c[cou];
                cou--;
            }
            if((ans[b[i]]==-1)&&(ans[a[i]]!=-1)){
         
                ans[b[i]]=c[cou];
                cou--;
            }
        }
    }


    cout<<csum-c[n-1]<<endl;
    for(int i=0;i<n;i++)cout<<ans[i]<<' ';
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
using namespace std;
int main()
{
    int n,a,b,c;
    scanf("%d",&n);
    for (int i = 0 ; i < n ; i++)
    {
        scanf("%d%d%d",&a,&b,&c);
        if (pow(a,2) == pow(b,2) + pow(c,2) || pow(b,2) == pow(a,2) + pow(c,2) || pow(c,2) == pow(a,2) + pow(b,2))
            printf("YES\n");
        else
            printf("NO\n");
    }
}

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

int main(void)
{
    string str;
    while (getline(cin, str) && str!="0") {
        int sum = 0;
        for(int i = 0; i < str.length(); ++i)
            sum += str[i] - '0';
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3172
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    cout<<n*(n+1)/2;
    return 0;
}

Measured memory_bytes: 256
module Main where

import Data.List
import Control.Monad
import Debug.Trace
 
readTuple :: Read a  => IO (a, a)
readTuple = do
    [f, s] <- readLs
    pure (f, s)

readLs :: Read a => IO [a]
readLs = fmap read . words <$> getLine

solve :: [Int] -> Int
solve hs = foldr (\cs acc -> if cs then acc + 1 else acc) 0 $  fmap inner $ zip [0..] hs
    where
        inner (0, value) = True
        inner (index, value) = all (<= value) $ take index hs


main = do
    _ <- getLine
    hs <- readLs
    print $ solve hs




Measured memory_bytes: 636
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main() 
  { 
  string s;
  cin>>s;
  int c=0;
  for(int i=0;i<s.length();i++)
    { 
    if(s[i]=='7')
      c++;
    }
  if(c>=1)
    cout<<"Yes"<<endl;
  else 
    cout<<"No"<<endl;
  return 0;
  }

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int n; 
int main()
{
	cin>>n;
	auto p = new int[n+5]();
	auto q = new int[100000+5]();
	
	for(int i=1;i<=n;i++)
	{
		cin>>p[i];
	}
	for(int i=1;i<=n;i+=2)
	{
		q[p[i]]++;
	}
	int mx1=0,mx2=0,id=0;	
	for(int i=1;i<=100000;i++)
	{
		if(q[i]>mx1)
		{
			id=i;
			mx2=mx1;
			mx1=q[i];
		}
		else if(q[i]>mx2)mx2=q[i];
	}
	
	auto qs = new int[100000+5]();
	
	int as=0;
	for(int i=2;i<=n;i+=2)
	{
		qs[p[i]]++;
	}
	int mn1(0),mn2(0),idd(0);
	for(int i=1;i<=100000;i++)
	{
		if(qs[i]>mn1)
		{
			mn2=mn1;
			mn1=qs[i];
			idd=i;
		}
		else if(qs[i]>mn2)mn2=qs[i];
	}
	if(id!=idd)cout<<n-mx1-mn1<<endl;
	else
	{
		cout<<n-max(mx1+mn2,mx2+mn1)<<endl;
	}
	return 0;
} 

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int v[10003];
int mat[103][103];
pair<int, int> way[4] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

int main() {

    ios::sync_with_stdio(false);

    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;

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

    int crrStep;
    int target1 = w;
    int target2 = h;
    int todo = target1;
    int nway = 0;
    bool flip = false;
    int color = 1;
    pair<int, int> pos = {1, 1};
    int TEST = 0;

    while(todo != 0) {

        while(v[color] == 0)
            color++;
        mat[pos.first][pos.second] = color;
        v[color]--;
        //cout << target1 << " " << target2 << '\n';
        TEST++;

        todo--;

        if(todo == 0) {

            flip = !flip;

            if(!flip) {
                todo = (--target1);
            } else {
                todo = (--target2);
            }

            nway = (nway+1)%4;

        }

        pos = {pos.first + way[nway].first, pos.second + way[nway].second};

    }

    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            cout << mat[i][j] << " ";
        }
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 384
//#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy 2333333
#define bql 2147483647
using namespace std;
int n;
int a[100005],b[100005];
long long ans=0;
int main()
{
	fast;
	cin>>n;
	for (int i=1;i<=n+1;i++)
		cin>>a[i];

	for (int i=1;i<=n;i++)
	{
		cin>>b[i];
		if (b[i]>=a[i])
		{
			b[i]-=a[i];
			ans+=a[i];
			a[i]=0;
			if (b[i]>=a[i+1])
			{
				ans+=a[i+1];
				a[i+1]=0;
			}
			else
			{
				a[i+1]-=b[i];
				ans+=b[i];
			}
		}
		else
		{
			ans+=b[i];
			a[i]-=b[i];
		}
	}
	
	cout<<ans<<endl;
	return 0;
}



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

struct Team{
    int id, solved, penalty;
    bool operator<(const Team &obj) const{
        if(this->solved > obj.solved)return true;
        else if(this->solved < obj.solved)return false;
        else if(this->penalty < obj.penalty)return true;
        else if(this->penalty > obj.penalty)return false;
        else if(this->id < obj.id)return true;
        else return false;
    }
};

Team teams[51] = {0};
int penalties[51][11] = {0};

int main(){
    int t, p, r;
    while(scanf("%d %d %d",&t,&p, &r), t != 0){
        for(int i=0;i<50;++i){
            teams[i] = (Team){0,0,0};
            for(int j=0;j<10;++j){
                penalties[i][j] = 0;
            }
        }
        for(int i=0;i<t;++i)teams[i].id = i+1;
        for(int i=0;i<r;++i){
            int tid, pid, tm;
            string mes;
            cin >> tid >> pid >> tm >> mes;
            if(mes[0] == 'C'){
                teams[tid-1].solved++;
                teams[tid-1].penalty += penalties[tid-1][pid-1] * 1200 + tm;
            }else{
                penalties[tid-1][pid-1]++;
            }
        }
        sort(teams, teams+t);
        for(int i=0;i<t;++i)cout << teams[i].id << " " << teams[i].solved << " " << teams[i].penalty << endl;
    }

    return 0;
}


Measured memory_bytes: 3196
n=int(input())

A=list(map(int,input().split()))

U=[0]
for i in range(n):
    U.append(U[i]+A[i])

U.sort()

lis=[]
nlis=[]
for ui in U:
    if lis==[] or lis[-1]!=ui:
        lis.append(ui)
        nlis.append(1)
    else:
        nlis[-1]+=1

c=0
for n in nlis:
    c+=(n*(n-1))//2

print(c)

Measured memory_bytes: 26720
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
const int N = 100000+10;
int pen[N],totpen,ans;
bool vis[N];
string res;
int p,n,m;
int main()
{
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
    	cin>>p>>res;
    	if(res=="WA"){
    		if(!vis[p]){
    			pen[p]++;
    		}
    		else{
    			continue;
    		}
    	}
    	else {
    		if(vis[p]){
    			continue;
    		}
    		else{
    			vis[p]=true;
    			totpen+=pen[p];
    			pen[p]=0;
    			ans++;
    		}
    	}
    }
    cout<<ans<<" "<<totpen<<endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll a, b, c;
  cin >> a >> b >> c;

  rep(i, 1000000) {
    if (i == 0) continue;
    if ((a * i) % b == c) {
      COUT("YES");
      return 0;
    }
  }
  COUT("NO");
  return 0;
}

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

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

typedef long long LL;
typedef unsigned long UL;

using namespace std;

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

    int h, w;
    cin >> h >> w;

    vector<string> in(h);

    REP(i, h)
    {
        in[i].resize(w);
        cin >> in[i];
    }

    in.erase(remove_if(in.begin(), in.end(), [=](string str) {bool ans = true; REP(i, w) if (str[i] != '.') ans = false; return ans; }), in.end());

    bool eraseable;
    vector<int> erase(0);
    for (int i = 0; i < in[0].size(); ++i)
    {
        eraseable = true;
        for (int j = 0; j < in.size(); ++j)
        {
            if (in[j][i] != '.') eraseable = false;
        }

        if (eraseable) erase.emplace_back(i);
    }

    for (auto& v : erase)
    {
        for (auto& x : in)
        {
            x.erase(x.begin() + v);
        }
        for (auto& y : erase) y -= 1;
    }

    for (const auto& v : in)
    {
        cout << v << endl;
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
N=int(input())
S=list(input())
alpa=list("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ")
for i in range(len(S)):
    for k in range(26):
        if S[i]==alpa[k]:
            S[i]=alpa[k+N]
            break
for n in range(len(S)):
    print(S[n],end="")

Measured memory_bytes: 4596
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = lc()

left = s[0]
right = s[-1]

# aba型のとき
if s[0] == s[-1]:
    if len(s)%2:
        print("Second")
    else:
        print("First")

# ab型のとき    
else:
    if len(s)%2:
        print("First")
    else:
        print("Second")
    

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

int main() {
  int r, D, x;
  cin >> r >> D >> x;
  vector<int> xxx(10);
  
  for (int i = 0; i < 10; i++){
    x *= r;
    x -= D;
    xxx.at(i) = x;
  }
  
  for (int i = 0; i < 10; i++){
    cout << xxx.at(i) << endl;
  }
  
}

Measured memory_bytes: 256